Class: OpenStax::Aws::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/openstax_aws.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



69
70
71
72
73
74
75
76
77
78
# File 'lib/openstax_aws.rb', line 69

def initialize
  @stack_waiter_delay = 30
  @stack_waiter_max_attempts = 180
  @cfn_template_bucket_folder = "cfn_templates"
  @infer_stack_capabilities = true
  @infer_parameter_defaults = true
  @production_env_name = "production"
  @default_cycle_if_different_parameter = "CycleIfDifferent"
  @required_stack_tags = %w(Application Environment Owner)
end

Instance Attribute Details

#cfn_template_bucket_folderObject

Returns the value of attribute cfn_template_bucket_folder.



58
59
60
# File 'lib/openstax_aws.rb', line 58

def cfn_template_bucket_folder
  @cfn_template_bucket_folder
end

#cfn_template_bucket_nameObject



85
86
87
88
# File 'lib/openstax_aws.rb', line 85

def cfn_template_bucket_name
  raise "cfn_template_bucket_name isn't set!" if @cfn_template_bucket_name.blank?
  @cfn_template_bucket_name
end

#cfn_template_bucket_regionObject



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/openstax_aws.rb', line 90

def cfn_template_bucket_region
  raise "cfn_template_bucket_region isn't set!" if @cfn_template_bucket_region.blank?
  @cfn_template_bucket_region

  # We used to find the region automagically with the following, but this played some havoc
  # with recorded test interactions (as it only ran in some tests since memoized).  Just
  # require manual setting now.
  #
  # @cfn_template_bucket_region ||= ::Aws::S3::Client.new(region: "us-east-1") # could be any region
  #   .get_bucket_location(bucket: cfn_template_bucket_name)
  #   .location_constraint
end

#default_cycle_if_different_parameterObject

Returns the value of attribute default_cycle_if_different_parameter.



66
67
68
# File 'lib/openstax_aws.rb', line 66

def default_cycle_if_different_parameter
  @default_cycle_if_different_parameter
end

#fixed_s3_template_folderObject

Returns the value of attribute fixed_s3_template_folder.



65
66
67
# File 'lib/openstax_aws.rb', line 65

def fixed_s3_template_folder
  @fixed_s3_template_folder
end

#infer_parameter_defaultsObject

Returns the value of attribute infer_parameter_defaults.



63
64
65
# File 'lib/openstax_aws.rb', line 63

def infer_parameter_defaults
  @infer_parameter_defaults
end

#infer_stack_capabilitiesObject

Returns the value of attribute infer_stack_capabilities.



62
63
64
# File 'lib/openstax_aws.rb', line 62

def infer_stack_capabilities
  @infer_stack_capabilities
end

#loggerObject



103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/openstax_aws.rb', line 103

def logger
  @logger ||= Logger.new(STDERR).tap do |the_logger|
    the_logger.formatter = proc do |severity, datetime, progname, msg|
      date_format = datetime.strftime("%Y-%m-%d %H:%M:%S.%3N")
      if severity == "INFO" or severity == "WARN"
          "[#{date_format}] #{severity}  | #{msg}\n"
      else
          "[#{date_format}] #{severity} | #{msg}\n"
      end
    end
  end
end

#production_env_nameObject

Returns the value of attribute production_env_name.



64
65
66
# File 'lib/openstax_aws.rb', line 64

def production_env_name
  @production_env_name
end

#required_stack_tagsObject



80
81
82
83
# File 'lib/openstax_aws.rb', line 80

def required_stack_tags
  # Make sure always returned as an array
  [@required_stack_tags].compact.uniq.flatten
end

#stack_waiter_delayObject

Returns the value of attribute stack_waiter_delay.



60
61
62
# File 'lib/openstax_aws.rb', line 60

def stack_waiter_delay
  @stack_waiter_delay
end

#stack_waiter_max_attemptsObject

Returns the value of attribute stack_waiter_max_attempts.



61
62
63
# File 'lib/openstax_aws.rb', line 61

def stack_waiter_max_attempts
  @stack_waiter_max_attempts
end

Instance Method Details

#without_required_stack_tagsObject

Sometimes you want to make a Stack object without requirng stack tags, e.g. if you’re just inspecting a stack. Wrapping such instantiations with this method enables this, e.g. without_required_stack_tags do … end



119
120
121
122
123
124
125
126
127
# File 'lib/openstax_aws.rb', line 119

def without_required_stack_tags
  begin
    original_required_stack_tags = required_stack_tags
    self.required_stack_tags = []
    yield
  ensure
    self.required_stack_tags = original_required_stack_tags
  end
end