Class: AwsHelpers::CloudFormation::PollStackStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_helpers/cloud_formation/poll_stack_status.rb

Instance Method Summary collapse

Constructor Details

#initialize(cloud_formation_client, stack_name) ⇒ PollStackStatus

Returns a new instance of PollStackStatus


8
9
10
# File 'lib/aws_helpers/cloud_formation/poll_stack_status.rb', line 8

def initialize(cloud_formation_client, stack_name)
  @describe_stack = DescribeStack.new(cloud_formation_client, stack_name)
end

Instance Method Details

#executeObject


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/aws_helpers/cloud_formation/poll_stack_status.rb', line 12

def execute

  loop do
    aws_stack = @describe_stack.execute
    status = aws_stack[:stack_status]
    name = aws_stack[:stack_name]
    puts "Stack - #{name} status #{status}"

    case status
      when CREATE_COMPLETE, DELETE_COMPLETE, ROLLBACK_COMPLETE, UPDATE_COMPLETE, UPDATE_ROLLBACK_COMPLETE, ROLLBACK_FAILED, UPDATE_ROLLBACK_FAILED, DELETE_FAILED
        break
      else
        sleep 30
    end
  end

end