in blogs/ecs-canary-deployments-pipeline/shared_stack/lambda_functions/rollbackto_previous_canary/main.py [0:0]
def _delete_stack(stack_name):
""" Delete the old version of CloudFormation stack """
retries = 3
while True:
try:
CFN_CLIENT.delete_stack(
StackName=stack_name
)
LOGGER.info("Waiting for stack to be deleted...")
waiter = CFN_CLIENT.get_waiter('stack_delete_complete')
waiter.wait(StackName=stack_name)
LOGGER.info("Deleted the Canary stack: %s successfully.", stack_name)
return True
except WaiterError as _ex:
retries-=1
if retries<1:
LOGGER.error("CloudFormation Stack deletion failed during the cleanup workflow.")
return False
LOGGER.info("Sleeping for 60seconds during the cleanup workflow before second attempt of cleanup.")
time.sleep(60)