Class: Stack
- Inherits:
-
Object
- Object
- Stack
- Defined in:
- lib/eops/stack.rb
Instance Method Summary collapse
- #create(template, stack_name, parameters = {}, wait = false) ⇒ Object
- #destroy(stack_name) ⇒ Object
-
#initialize ⇒ Stack
constructor
A new instance of Stack.
- #list ⇒ Object
Constructor Details
#initialize ⇒ Stack
Returns a new instance of Stack.
3 4 5 |
# File 'lib/eops/stack.rb', line 3 def initialize @cfn = AWS::CloudFormation.new end |
Instance Method Details
#create(template, stack_name, parameters = {}, wait = false) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/eops/stack.rb', line 7 def create(template, stack_name, parameters = {}, wait=false) stack = @cfn.stacks.create(stack_name, File.open(template, "r").read, :parameters => parameters, :capabilities => ["CAPABILITY_IAM"], :disable_rollback => true) if wait while stack.status != "CREATE_COMPLETE" sleep 30 case stack.status when "ROLLBACK_IN_PROGESS" stack.delete when "ROLLBACK_COMPLETE" stack.delete end end end end |
#destroy(stack_name) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/eops/stack.rb', line 28 def destroy(stack_name) stack = @cfn.stacks[stack_name] stack.delete while stack.exists? sleep 30 end end |
#list ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/eops/stack.rb', line 36 def list @cfn.stacks.each do |stack| case stack.status when "CREATE_COMPLETE" puts "Stack Name: #{stack.name} | Status: Available" when "CREATE_IN_PROGRESS" puts "Stack Name: #{stack.name} | Status: In Progress" end end end |