Sha256: 2176e547bacbafdf41202a520d82df169cd8946869c834e282fb18e7610c6967
Contents?: true
Size: 1.27 KB
Versions: 4
Compression:
Stored size: 1.27 KB
Contents
require "aws-sdk-cloudformation" module Lono::Cfn::AwsServices def cfn @cfn ||= Aws::CloudFormation::Client.new end def stack_exists?(stack_name) return true if testing_update? return false if @options[: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 resp = 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:/._+]*" puts "Invalid stack name: #{stack_name}" puts "Full error message: #{e.message}" exit 1 else raise # re-raise exception because unsure what other errors can happen end end exist end def testing_update? ENV['TEST'] && self.class.name == "LonoCfn::Update" end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
lono-3.5.0 | lib/lono/cfn/aws_services.rb |
lono-3.4.1 | lib/lono/cfn/aws_services.rb |
lono-3.4.0 | lib/lono/cfn/aws_services.rb |
lono-3.3.4 | lib/lono/cfn/aws_services.rb |