class OpenStax::Aws::Configuration

Attributes

cfn_template_bucket_folder[RW]
cfn_template_bucket_name[W]
cfn_template_bucket_region[W]
default_cycle_if_different_parameter[RW]
fixed_s3_template_folder[RW]
infer_parameter_defaults[RW]
infer_stack_capabilities[RW]
logger[W]
production_env_name[RW]
required_stack_tags[W]
stack_waiter_delay[RW]
stack_waiter_max_attempts[RW]

Public Class Methods

new() click to toggle source
# 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

Public Instance Methods

cfn_template_bucket_name() click to toggle source
# 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_region() click to toggle source
# 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
logger() click to toggle source
# 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
required_stack_tags() click to toggle source
# 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
without_required_stack_tags() { || ... } click to toggle source

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

# 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