class Stax::Aws::Cfn
Constants
- COLORS
- STATUSES
stack statuses that are not DELETE_COMPLETE
Public Class Methods
cancel(name)
click to toggle source
# File lib/stax/aws/cfn.rb, line 121 def cancel(name) client.cancel_update_stack(stack_name: name) end
changes(opt)
click to toggle source
# File lib/stax/aws/cfn.rb, line 143 def changes(opt) paginate(:changes) do |next_token| client.describe_change_set(opt.merge(next_token: next_token)) end end
changeset(opt)
click to toggle source
# File lib/stax/aws/cfn.rb, line 149 def changeset(opt) client.create_change_set(opt) end
client()
click to toggle source
# File lib/stax/aws/cfn.rb, line 33 def client @_client ||= ::Aws::CloudFormation::Client.new(retry_limit: Stax::Aws::Sdk::RETRY_LIMIT) end
create(opt)
click to toggle source
# File lib/stax/aws/cfn.rb, line 109 def create(opt) client.create_stack(opt)&.stack_id end
delete(name)
click to toggle source
# File lib/stax/aws/cfn.rb, line 117 def delete(name) client.delete_stack(stack_name: name) end
describe(name)
click to toggle source
# File lib/stax/aws/cfn.rb, line 67 def describe(name) client.describe_stacks(stack_name: name).stacks.first rescue ::Aws::CloudFormation::Errors::ValidationError nil end
detect_drift(opt)
click to toggle source
# File lib/stax/aws/cfn.rb, line 157 def detect_drift(opt) client.detect_stack_drift(opt).stack_drift_detection_id end
drift_status(id)
click to toggle source
# File lib/stax/aws/cfn.rb, line 161 def drift_status(id) client.describe_stack_drift_detection_status(stack_drift_detection_id: id) end
drifts(opt)
click to toggle source
# File lib/stax/aws/cfn.rb, line 165 def drifts(opt) client.describe_stack_resource_drifts(opt).map(&:stack_resource_drifts).flatten end
events(name)
click to toggle source
# File lib/stax/aws/cfn.rb, line 55 def events(name) client.describe_stack_events(stack_name: name).map(&:stack_events).flatten end
execute(opt)
click to toggle source
# File lib/stax/aws/cfn.rb, line 153 def execute(opt) client.execute_change_set(opt) end
exists?(name)
click to toggle source
# File lib/stax/aws/cfn.rb, line 73 def exists?(name) Aws::Cfn.describe(name) && true rescue ::Aws::CloudFormation::Errors::ValidationError false end
exports(name)
click to toggle source
list of this stack output exports
# File lib/stax/aws/cfn.rb, line 90 def exports(name) describe(name).outputs.select(&:export_name) end
get_policy(opt)
click to toggle source
# File lib/stax/aws/cfn.rb, line 129 def get_policy(opt) client.get_stack_policy(opt).stack_policy_body end
id(name, id)
click to toggle source
# File lib/stax/aws/cfn.rb, line 59 def id(name, id) client.describe_stack_resource(stack_name: name, logical_resource_id: id).stack_resource_detail.physical_resource_id end
imports(name)
click to toggle source
list of stacks that import from this one
# File lib/stax/aws/cfn.rb, line 95 def imports(name) client.list_imports(export_name: name).map(&:imports) rescue ::Aws::CloudFormation::Errors::ValidationError [] rescue ::Aws::CloudFormation::Errors::Throttling => e # this call rate-limits aggressively warn(e.message) sleep 1 retry end
list_change_sets(name)
click to toggle source
# File lib/stax/aws/cfn.rb, line 137 def list_change_sets(name) paginate(:summaries) do |next_token| client.list_change_sets(stack_name: name, next_token: next_token) end end
output(name, key)
click to toggle source
# File lib/stax/aws/cfn.rb, line 85 def output(name, key) outputs(name)[key] end
outputs(name)
click to toggle source
# File lib/stax/aws/cfn.rb, line 79 def outputs(name) describe(name).outputs.each_with_object(HashWithIndifferentAccess.new) do |o, h| h[o.output_key] = o.output_value end end
parameters(name)
click to toggle source
# File lib/stax/aws/cfn.rb, line 63 def parameters(name) client.describe_stacks(stack_name: name).stacks.first.parameters end
protection(name, enable)
click to toggle source
# File lib/stax/aws/cfn.rb, line 125 def protection(name, enable) client.update_termination_protection(stack_name: name, enable_termination_protection: enable) end
resources(name)
click to toggle source
# File lib/stax/aws/cfn.rb, line 45 def resources(name) client.list_stack_resources(stack_name: name).map(&:stack_resource_summaries).flatten end
resources_by_type(name, type)
click to toggle source
# File lib/stax/aws/cfn.rb, line 49 def resources_by_type(name, type) resources(name).select do |r| r.resource_type == type end end
set_policy(opt)
click to toggle source
# File lib/stax/aws/cfn.rb, line 133 def set_policy(opt) client.set_stack_policy(opt) end
stacks()
click to toggle source
# File lib/stax/aws/cfn.rb, line 37 def stacks client.list_stacks(stack_status_filter: STATUSES).map(&:stack_summaries).flatten end
template(name)
click to toggle source
# File lib/stax/aws/cfn.rb, line 41 def template(name) client.get_template(stack_name: name).template_body end
update(opt)
click to toggle source
# File lib/stax/aws/cfn.rb, line 113 def update(opt) client.update_stack(opt)&.stack_id end
validate(opt)
click to toggle source
# File lib/stax/aws/cfn.rb, line 105 def validate(opt) client.validate_template(opt) end