Class: Chef::Knife::CloudformationDescribe
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::CloudformationDescribe
- Includes:
- KnifeCloudformation::Knife::Base
- Defined in:
- lib/chef/knife/cloudformation_describe.rb
Overview
Cloudformation describe command
Constant Summary collapse
- AVAILABLE_DISPLAYS =
[:resources, :outputs]
Instance Method Summary collapse
-
#_run ⇒ Object
Run the stack describe action.
-
#default_attributes ⇒ Array<String>
Default attributes.
-
#outputs(stack) ⇒ Object
Display outputs.
-
#resources(stack) ⇒ Object
Display resources.
Methods included from KnifeCloudformation::Knife::Base
Instance Method Details
#_run ⇒ Object
Run the stack describe action
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/chef/knife/cloudformation_describe.rb', line 42 def _run stack_name = name_args.last stack = provider.connection.stacks.get(stack_name) if(stack) display = [].tap do |to_display| AVAILABLE_DISPLAYS.each do |display_option| if(config[display_option]) to_display << display_option end end end display = AVAILABLE_DISPLAYS.dup if display.empty? display.each do |display_method| self.send(display_method, stack) ui.info '' end else ui.fatal "Failed to find requested stack: #{ui.color(stack_name, :bold, :red)}" exit -1 end end |
#default_attributes ⇒ Array<String>
Returns default attributes.
93 94 95 |
# File 'lib/chef/knife/cloudformation_describe.rb', line 93 def default_attributes %w(updated logical_id type status status_reason) end |
#outputs(stack) ⇒ Object
Display outputs
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/chef/knife/cloudformation_describe.rb', line 79 def outputs(stack) ui.info "Outputs for stack: #{ui.color(stack.name, :bold)}" unless(stack.outputs.empty?) stack.outputs.each do |output| key, value = output.key, output.value key = snake(key).to_s.split('_').map(&:capitalize).join(' ') ui.info [' ', ui.color("#{key}:", :bold), value].join(' ') end else ui.info " #{ui.color('No outputs found')}" end end |
#resources(stack) ⇒ Object
Display resources
67 68 69 70 71 72 73 74 |
# File 'lib/chef/knife/cloudformation_describe.rb', line 67 def resources(stack) stack_resources = stack.resources.all.sort do |x, y| y.updated <=> x.updated end.map do |resource| Mash.new(resource.attributes) end things_output(stack.name, stack_resources, :resources) end |