Sha256: 9b9f7067ff1d7d963f39fbf92c0a98b68c3a4116c7ebd7e856c2e4192153c87b

Contents?: true

Size: 871 Bytes

Versions: 2

Compression:

Stored size: 871 Bytes

Contents

# frozen_string_literal: true

module AwsAsCode
  module Concerns
    module AwsTaskHelpers
      private

      def semaphore
        StackStateSemaphore.new logger: logger
      end

      def exit_code_for_stack_state(stack)
        state_indicates_failure?(stack) ? 1 : 0
      end

      def state_indicates_failure?(stack)
        stack.stack_status =~ /ROLLBACK/ || stack.stack_status =~ /FAILED/
      end

      def cloud_formation
        @cloud_formation ||= Aws::CloudFormation::Client.new
      end

      def s3
        @s3 ||= Aws::S3::Resource.new
      end

      def stack
        @stack ||= Aws::CloudFormation::Stack.new config.stack
      end

      def template_object
        bucket = s3.bucket config.bucket
        prefix = "#{config.stack}/#{config.version}"
        bucket.object "#{prefix}/#{config.template}.json"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aws_as_code-1.0.6 lib/aws_as_code/concerns/aws_task_helpers.rb
aws_as_code-1.0.5 lib/aws_as_code/concerns/aws_task_helpers.rb