Class: Stackup::ChangeSet
- Inherits:
-
Object
- Object
- Stackup::ChangeSet
- Includes:
- ErrorHandling
- Defined in:
- lib/stackup/change_set.rb
Overview
An abstraction of a CloudFormation change-set.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
Instance Method Summary collapse
-
#create(options = {}) ⇒ String
Create the change-set.
-
#delete ⇒ Object
Delete a change-set.
-
#describe ⇒ Object
Describe the change-set.
-
#execute ⇒ String
Execute the change-set.
-
#initialize(name, stack) ⇒ ChangeSet
constructor
A new instance of ChangeSet.
- #status ⇒ Object
Methods included from ErrorHandling
Constructor Details
#initialize(name, stack) ⇒ ChangeSet
Returns a new instance of ChangeSet.
11 12 13 14 |
# File 'lib/stackup/change_set.rb', line 11 def initialize(name, stack) @name = name @stack = stack end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/stackup/change_set.rb', line 16 def name @name end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
17 18 19 |
# File 'lib/stackup/change_set.rb', line 17 def stack @stack end |
Instance Method Details
#create(options = {}) ⇒ String
Create the change-set.
Refer Aws::CloudFormation::Client#create_change_set
(see http://docs.aws.amazon.com/sdkforruby/api/Aws/CloudFormation/Client.html#create_change_set-instance_method)
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/stackup/change_set.rb', line 55 def create( = {}) = () delete if .delete(:force) allow_empty_change_set = .delete(:allow_empty_change_set) handling_cf_errors do cf_client.create_change_set() loop do current = describe logger.debug("change_set_status=#{current.status}") case current.status when /COMPLETE/ return current.status when "FAILED" if allow_empty_change_set && (current.status_reason == "The submitted information didn't contain changes. Submit different information to create a change set.") return current.status_reason end logger.error(current.status_reason) raise StackUpdateError, "change-set creation failed" if status == "FAILED" end sleep(wait_poll_interval) end status end end |
#delete ⇒ Object
Delete a change-set.
98 99 100 101 102 103 |
# File 'lib/stackup/change_set.rb', line 98 def delete handling_cf_errors do cf_client.delete_change_set(:stack_name => stack.name, :change_set_name => name) end nil end |
#describe ⇒ Object
Describe the change-set.
Refer Aws::CloudFormation::Client#describe_change_set
(http://docs.aws.amazon.com/sdkforruby/api/Aws/CloudFormation/Client.html#describe_change_set-instance_method)
116 117 118 119 120 |
# File 'lib/stackup/change_set.rb', line 116 def describe handling_cf_errors do cf_client.describe_change_set(:stack_name => stack.name, :change_set_name => name) end end |
#execute ⇒ String
Execute the change-set.
88 89 90 91 92 |
# File 'lib/stackup/change_set.rb', line 88 def execute modify_stack(/(CREATE|UPDATE)_COMPLETE/, "update failed") do cf_client.execute_change_set(:stack_name => stack.name, :change_set_name => name) end end |
#status ⇒ Object
105 106 107 |
# File 'lib/stackup/change_set.rb', line 105 def status describe.status end |