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.



62
63
64
65
66
67
68
69
70
71
# File 'lib/openstax_aws.rb', line 62

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.



51
52
53
# File 'lib/openstax_aws.rb', line 51

def cfn_template_bucket_folder
  @cfn_template_bucket_folder
end

#cfn_template_bucket_nameObject



78
79
80
81
# File 'lib/openstax_aws.rb', line 78

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



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/openstax_aws.rb', line 83

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.



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

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.



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

def fixed_s3_template_folder
  @fixed_s3_template_folder
end

#infer_parameter_defaultsObject

Returns the value of attribute infer_parameter_defaults.



56
57
58
# File 'lib/openstax_aws.rb', line 56

def infer_parameter_defaults
  @infer_parameter_defaults
end

#infer_stack_capabilitiesObject

Returns the value of attribute infer_stack_capabilities.



55
56
57
# File 'lib/openstax_aws.rb', line 55

def infer_stack_capabilities
  @infer_stack_capabilities
end

#loggerObject



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/openstax_aws.rb', line 96

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.



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

def production_env_name
  @production_env_name
end

#required_stack_tagsObject



73
74
75
76
# File 'lib/openstax_aws.rb', line 73

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.



53
54
55
# File 'lib/openstax_aws.rb', line 53

def stack_waiter_delay
  @stack_waiter_delay
end

#stack_waiter_max_attemptsObject

Returns the value of attribute stack_waiter_max_attempts.



54
55
56
# File 'lib/openstax_aws.rb', line 54

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



112
113
114
115
116
117
118
119
120
# File 'lib/openstax_aws.rb', line 112

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