Module: OpenStax::Aws

Defined in:
lib/openstax_aws.rb,
lib/openstax/aws/tag.rb,
lib/openstax/aws/alarm.rb,
lib/openstax/aws/image.rb,
lib/openstax/aws/stack.rb,
lib/openstax/aws/system.rb,
lib/openstax/aws/secrets.rb,
lib/openstax/aws/version.rb,
lib/openstax/aws/template.rb,
lib/openstax/aws/sam_stack.rb,
lib/openstax/aws/change_set.rb,
lib/openstax/aws/event_rule.rb,
lib/openstax/aws/git_helper.rb,
lib/openstax/aws/msk_cluster.rb,
lib/openstax/aws/secrets_set.rb,
lib/openstax/aws/stack_event.rb,
lib/openstax/aws/distribution.rb,
lib/openstax/aws/packer_1_2_5.rb,
lib/openstax/aws/packer_1_4_1.rb,
lib/openstax/aws/rds_instance.rb,
lib/openstax/aws/s3_text_file.rb,
lib/openstax/aws/stack_status.rb,
lib/openstax/aws/wait_message.rb,
lib/openstax/aws/stack_factory.rb,
lib/openstax/aws/packer_factory.rb,
lib/openstax/aws/deployment_base.rb,
lib/openstax/aws/secrets_factory.rb,
lib/openstax/aws/resource_factory.rb,
lib/openstax/aws/stack_parameters.rb,
lib/openstax/aws/ec2_instance_data.rb,
lib/openstax/aws/auto_scaling_group.rb,
lib/openstax/aws/auto_scaling_instance.rb,
lib/openstax/aws/build_image_command_1.rb,
lib/openstax/aws/secrets_specification.rb

Defined Under Namespace

Modules: GitHelper, System Classes: Alarm, AutoScalingGroup, AutoScalingInstance, BuildImageCommand1, ChangeSet, Configuration, DeploymentBase, Distribution, Ec2InstanceData, EventRule, Image, MskCluster, PackerFactory, Packer_1_2_5, Packer_1_4_1, RdsInstance, ResourceFactory, S3TextFile, SamStack, Secrets, SecretsFactory, SecretsSet, SecretsSpecification, SecretsSpecificationFactory, SecretsSubstitutionsFactory, Stack, StackFactory, StackParameters, Tag, Template, WaitMessage

Constant Summary collapse

VERSION =
"2.0.1"

Class Method Summary collapse

Class Method Details

.configurationObject



47
48
49
# File 'lib/openstax_aws.rb', line 47

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



43
44
45
# File 'lib/openstax_aws.rb', line 43

def self.configure
  yield configuration
end

.loggerObject



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

def self.logger
  configuration.logger
end

.verify_secrets_populated!Object



20
21
22
23
24
# File 'lib/openstax_aws.rb', line 20

def self.verify_secrets_populated!
  if ENV['AWS_ACCESS_KEY_ID'].nil? || ENV['AWS_SECRET_ACCESS_KEY'].nil?
    raise "AWS key and secret are not both set!"
  end
end

.verify_template_bucket_access!Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/openstax_aws.rb', line 26

def self.verify_template_bucket_access!
  begin
    ::Aws::S3::Client.new(region: configuration.cfn_template_bucket_region)
                   .head_bucket(bucket: configuration.cfn_template_bucket_name)
  rescue ::Aws::S3::Errors::Forbidden
    # If get_caller_identity throws, that is fine, we get a nice error message from it
    id = ::Aws::STS::Client.new(
      region: configuration.cfn_template_bucket_region
    ).get_caller_identity

    raise "Your current role or user, \"#{id.arn}\", cannot access the CFN template bucket \"#{
      configuration.cfn_template_bucket_name}\" in the \"#{
      configuration.cfn_template_bucket_region}\" region. " \
      "Please verify that you are using the correct role and account."
  end
end