class Shelter::CLI::Stack::CloudFormation
CloudFormation
based stack base
Attributes
_attr[RW]
Public Class Methods
set_attr(name, value)
click to toggle source
# File lib/cli/stack/cloud_formation.rb 68 def set_attr(name, value) 69 self._attr ||= { 70 tags: {}, 71 parameters: {} 72 } 73 self._attr[name] = value 74 end
Public Instance Methods
create()
click to toggle source
# File lib/cli/stack/cloud_formation.rb 34 def create 35 cf_client.create_stack( 36 stack_name: get_attr(:stack_name), 37 capabilities: get_attr(:capabilities), 38 template_body: File.open(get_attr(:template_file)).read, 39 tags: meta, parameters: stack_params(get_attr(:parameters)) 40 ) 41 wait_until(:stack_create_complete, get_attr(:stack_name)) 42 end
delete()
click to toggle source
# File lib/cli/stack/cloud_formation.rb 58 def delete 59 raise 'Stack is not deletable!!!' unless get_attr(:deletable) 60 cf_client.delete_stack(stack_name: get_attr(:stack_name)) 61 wait_until(:stack_delete_complete, get_attr(:stack_name)) 62 end
get_attr(name)
click to toggle source
# File lib/cli/stack/cloud_formation.rb 77 def get_attr(name) 78 self.class._attr[name] if self.class._attr.key? name 79 end
meta()
click to toggle source
# File lib/cli/stack/cloud_formation.rb 86 def meta 87 stack_meta( 88 get_attr(:tags).merge( 89 client: get_attr(:meta)[:client], 90 application: get_attr(:meta)[:application] 91 ), 92 type: get_attr(:meta)[:type] 93 ) 94 end
output()
click to toggle source
# File lib/cli/stack/cloud_formation.rb 25 def output 26 stack = cf_client.describe_stacks( 27 stack_name: get_attr(:stack_name) 28 ).stacks.first 29 30 stack.outputs.each { |out| display_stack_output(out) } 31 end
status()
click to toggle source
# File lib/cli/stack/cloud_formation.rb 12 def status 13 stack = cf_client.describe_stacks( 14 stack_name: get_attr(:stack_name) 15 ).stacks.first 16 17 cf_client.describe_stack_resources( 18 stack_name: stack.stack_name 19 ).stack_resources.each { |r| display_stack_resource(r) } 20 rescue Aws::CloudFormation::Errors::ValidationError 21 puts "#{get_attr(:stack_name)} does not exist" 22 end
update()
click to toggle source
# File lib/cli/stack/cloud_formation.rb 45 def update 46 cf_client.update_stack( 47 stack_name: get_attr(:stack_name), 48 capabilities: get_attr(:capabilities), 49 template_body: File.open(get_attr(:template_file)).read, 50 tags: meta, parameters: stack_params(get_attr(:parameters)) 51 ) 52 wait_until(:stack_update_complete, get_attr(:stack_name)) 53 rescue Aws::CloudFormation::Errors::ValidationError => e 54 puts e.message 55 end