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.



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

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.



49
50
51
# File 'lib/openstax_aws.rb', line 49

def cfn_template_bucket_folder
  @cfn_template_bucket_folder
end

#cfn_template_bucket_nameObject



76
77
78
79
# File 'lib/openstax_aws.rb', line 76

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



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

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.



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

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.



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

def fixed_s3_template_folder
  @fixed_s3_template_folder
end

#infer_parameter_defaultsObject

Returns the value of attribute infer_parameter_defaults.



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

def infer_parameter_defaults
  @infer_parameter_defaults
end

#infer_stack_capabilitiesObject

Returns the value of attribute infer_stack_capabilities.



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

def infer_stack_capabilities
  @infer_stack_capabilities
end

#loggerObject



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

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.



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

def production_env_name
  @production_env_name
end

#required_stack_tagsObject



71
72
73
74
# File 'lib/openstax_aws.rb', line 71

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.



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

def stack_waiter_delay
  @stack_waiter_delay
end

#stack_waiter_max_attemptsObject

Returns the value of attribute stack_waiter_max_attempts.



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

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



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

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