Class: StackMaster::TestDriver::CloudFormation
- Inherits:
-
Object
- Object
- StackMaster::TestDriver::CloudFormation
- Defined in:
- lib/stack_master/test_driver/cloud_formation.rb
Instance Method Summary collapse
- #add_stack(stack) ⇒ Object
- #add_stack_event(event) ⇒ Object
- #add_stack_resource(options) ⇒ Object
- #create_stack(options) ⇒ Object
- #delete_stack(options) ⇒ Object
- #describe_stack_events(options) ⇒ Object
- #describe_stack_resources(options = {}) ⇒ Object
- #describe_stacks(options = {}) ⇒ Object
- #get_stack_policy(options) ⇒ Object
- #get_template(options) ⇒ Object
-
#initialize ⇒ CloudFormation
constructor
A new instance of CloudFormation.
- #reset ⇒ Object
- #set_region(region) ⇒ Object
- #set_template(stack_name, template) ⇒ Object
- #update_stack(options) ⇒ Object
- #validate_template(options) ⇒ Object
Constructor Details
#initialize ⇒ CloudFormation
Returns a new instance of CloudFormation.
49 50 51 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 49 def initialize reset end |
Instance Method Details
#add_stack(stack) ⇒ Object
119 120 121 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 119 def add_stack(stack) @stacks[stack.fetch(:stack_name)] = Stack.new(stack) end |
#add_stack_event(event) ⇒ Object
132 133 134 135 136 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 132 def add_stack_event(event) stack_name = event.fetch(:stack_name) @stack_events[stack_name] ||= [] @stack_events[stack_name] << StackEvent.new(event) end |
#add_stack_resource(options) ⇒ Object
123 124 125 126 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 123 def add_stack_resource() @stack_resources[.fetch(:stack_name)] ||= [] @stack_resources[.fetch(:stack_name)] << StackResource.new() end |
#create_stack(options) ⇒ Object
104 105 106 107 108 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 104 def create_stack() stack_name = .fetch(:stack_name) add_stack() @stack_policies[stack_name] = [:stack_policy_body] end |
#delete_stack(options) ⇒ Object
110 111 112 113 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 110 def delete_stack() stack_name = .fetch(:stack_name) @stacks.delete(stack_name) end |
#describe_stack_events(options) ⇒ Object
93 94 95 96 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 93 def describe_stack_events() events = @stack_events[.fetch(:stack_name)] || [] OpenStruct.new(stack_events: events, next_token: nil) end |
#describe_stack_resources(options = {}) ⇒ Object
79 80 81 82 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 79 def describe_stack_resources( = {}) @stacks.fetch(.fetch(:stack_name)) { raise Aws::CloudFormation::Errors::ValidationError.new('', 'Stack does not exist') } OpenStruct.new(stack_resources: @stack_resources[.fetch(:stack_name)]) end |
#describe_stacks(options = {}) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 65 def describe_stacks( = {}) stack_name = [:stack_name] stacks = if stack_name if @stacks[stack_name] [@stacks[stack_name]] else raise Aws::CloudFormation::Errors::ValidationError.new('', 'Stack does not exist') end else @stacks.values end OpenStruct.new(stacks: stacks, next_token: nil) end |
#get_stack_policy(options) ⇒ Object
89 90 91 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 89 def get_stack_policy() OpenStruct.new(stack_policy_body: @stack_policies[.fetch(:stack_name)]) end |
#get_template(options) ⇒ Object
84 85 86 87 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 84 def get_template() template_body = @templates[[:stack_name]] || nil OpenStruct.new(template_body: template_body) end |
#reset ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 57 def reset @stacks = {} @templates = {} @stack_events = {} @stack_resources = {} @stack_policies = {} end |
#set_region(region) ⇒ Object
53 54 55 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 53 def set_region(region) @region = region end |
#set_template(stack_name, template) ⇒ Object
128 129 130 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 128 def set_template(stack_name, template) @templates[stack_name] = template end |
#update_stack(options) ⇒ Object
98 99 100 101 102 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 98 def update_stack() stack_name = .fetch(:stack_name) @stacks[stack_name].attributes = @stack_policies[stack_name] = [:stack_policy_body] end |
#validate_template(options) ⇒ Object
115 116 117 |
# File 'lib/stack_master/test_driver/cloud_formation.rb', line 115 def validate_template() true end |