Sha256: a10d8d6b81028579789a2f2111eb2ede8d90599421e0da7ddb63f78863b840e2
Contents?: true
Size: 1.76 KB
Versions: 2
Compression:
Stored size: 1.76 KB
Contents
module Lono::AwsServices module Helper def stack_exists?(stack_name) return false if ENV['LONO_NOOP'] exist = nil begin # When the stack does not exist an exception is raised. Example: # Aws::CloudFormation::Errors::ValidationError: Stack with id blah does not exist cfn.describe_stacks(stack_name: stack_name) exist = true rescue Aws::CloudFormation::Errors::ValidationError => e if e.message =~ /does not exist/ exist = false elsif e.message.include?("'stackName' failed to satisfy constraint") # Example of e.message when describe_stack with invalid stack name # "1 validation error detected: Value 'instance_and_route53' at 'stackName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]*|arn:[-a-zA-Z0-9:/._+]*" logger.info "Invalid stack name: #{stack_name}" logger.info "Full error message: #{e.message}" exit 1 else raise # re-raise exception because unsure what other errors can happen end end exist end def find_stack(stack_name) resp = cfn.describe_stacks(stack_name: stack_name) resp.stacks.first rescue Aws::CloudFormation::Errors::ValidationError => e # example: Stack with id demo-web does not exist if e.message =~ /Stack with/ && e.message =~ /does not exist/ nil else raise end end def find_stack_resources(stack_name) resp = cfn.describe_stack_resources(stack_name: stack_name) resp.stack_resources rescue Aws::CloudFormation::Errors::ValidationError => e if e.message.include?("does not exist") nil else raise end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lono-8.0.0.pre.rc2 | lib/lono/aws_services/helper.rb |
lono-8.0.0.pre.rc1 | lib/lono/aws_services/helper.rb |