Sha256: 403481e64fa0c9bae267406d0e383d341114a176c7e4ebed5f54c3246ec1a371

Contents?: true

Size: 889 Bytes

Versions: 10

Compression:

Stored size: 889 Bytes

Contents

module CfnManage

  module CloudFormation

    class Common

      def self.visit_stack(cf_client, stack_name, handler, visit_substacks)
        stack_resources = cf_client.describe_stack_resources(stack_name: stack_name)
        stack = cf_client.describe_stacks(stack_name: stack_name)

        # call traverse handler for parent stack
        handler.call(stack['stacks'][0].stack_name)

        # do not traverse unless instructed
        return unless visit_substacks

        stack_resources['stack_resources'].each do |resource|
          # test if resource us substack
          if resource['resource_type'] == 'AWS::CloudFormation::Stack'
            # call recursively
            substack_name = resource['physical_resource_id'].split('/')[1]
            self.visit_stack(cf_client, substack_name, handler, visit_substacks)
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cfn_manage-0.8.3 lib/cfn_manage/cf_common.rb
cfn_manage-0.8.2 lib/cfn_manage/cf_common.rb
cfn_manage-0.8.1 lib/cfn_manage/cf_common.rb
cfn_manage-0.8.0 lib/cfn_manage/cf_common.rb
cfn_manage-0.7.1 lib/cfn_manage/cf_common.rb
cfn_manage-0.7.0 lib/cfn_manage/cf_common.rb
cfn_manage-0.6.0 lib/cfn_manage/cf_common.rb
cfn_manage-0.5.5 lib/cfn_manage/cf_common.rb
cfn_manage-0.5.4 lib/cfn_manage/cf_common.rb
cfn_manage-0.5.3 lib/cfn_manage/cf_common.rb