Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Provide hook point in cfn_delete after confirm but before DeleteStack…
Browse files Browse the repository at this point in the history
… call

This is used by bootstrap-salt to delete a file that it manages in an s3
bucket that would otherwise stop the stack from deleting.
  • Loading branch information
ashb committed Aug 7, 2015
1 parent 527c5dd commit aef300f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,11 @@
## Version 0.5.x

* Provide hook point in cfn_delete fab task after confirm but before
DeleteStack call.

This is used by bootstrap-salt to remove a file that it places and manages
in an S3 bucket so that the stack can be cleanly deleted.

## Version 0.5.6
* Automaticly generate the RDS identifier

Expand Down
10 changes: 9 additions & 1 deletion bootstrap_cfn/fab_tasks.py
Expand Up @@ -282,7 +282,7 @@ def get_connection(klass):


@task
def cfn_delete(force=False):
def cfn_delete(force=False, pre_delete_callbacks=None):
"""
Delete the AWS Cloudformation stack
Expand All @@ -291,6 +291,10 @@ def cfn_delete(force=False):
Args:
force(bool): True to destroy the stack without any further
input, False to require confirmation before deletion
pre_delete_callbacks(list of callables): callable to invoke before
trying to run the DeleteStack call. Each callback is called with
kwargs of ``stack_name``, and ``config``. (Python only, not setable from
command line)
"""
if not force:
x = raw_input("Are you really sure you want to blow away the whole stack!? (y/n)\n")
Expand All @@ -302,6 +306,10 @@ def cfn_delete(force=False):
cfn.delete(stack_name)
print green("\nSTACK {0} DELETING...\n").format(stack_name)

if pre_delete_callbacks is not None:
for callback in pre_delete_callbacks:
callback(stack_name=stack_name, config=cfn_config)

if not env.blocking:
print 'Running in non blocking mode. Exiting.'
sys.exit(0)
Expand Down

0 comments on commit aef300f

Please sign in to comment.