class AwsCftTools::Runbooks::Retract
Retract
- manage CloudFormation stack retraction
@example
% aws-cft retract -e QA # delete all templates in the QA environment % aws-cft retract -e Staging -n -v # narrate the templates that would be deleted in Staging % aws-cft retract -e Production -c -v # narrate the changes implied by deleting stacks in Production
Public Instance Methods
run()
click to toggle source
# File lib/aws_cft_tools/runbooks/retract.rb, line 28 def run report_template_dependencies detail do tp(free_templates, ['filename']) end remove_deployed_templates end
Private Instance Methods
error_on_dependencies(templates)
click to toggle source
# File lib/aws_cft_tools/runbooks/retract.rb, line 65 def error_on_dependencies(templates) puts '*** Unable to remove templates.' puts 'The following templates are dependencies for templates not marked for removal: ', templates exit 1 end
remove_deployed_template(template)
click to toggle source
# File lib/aws_cft_tools/runbooks/retract.rb, line 47 def remove_deployed_template(template) operation("Removing: #{template.name}") do checking { narrate_changes(client.changes_on_stack_delete(template, changeset_set)) } doing { client.delete_stack(template) } end end
remove_deployed_templates()
click to toggle source
run appropriate update function against deployed templates/stacks
# File lib/aws_cft_tools/runbooks/retract.rb, line 43 def remove_deployed_templates free_templates.each(&method(:remove_deployed_template)) end
report_template_dependencies()
click to toggle source
report_undefined_image - provide list of undefined imports that block stack deployment
# File lib/aws_cft_tools/runbooks/retract.rb, line 57 def report_template_dependencies free = free_templates deployed = client.stacks.map(&:name) all = templates.select { |template| deployed.include?(template.name) } diff = (all - free).map { |template| template.filename.to_s } error_on_dependencies(diff) if diff.any? end