cloudtools / stacker

An AWS CloudFormation Stack orchestrator/manager.
http://stacker.readthedocs.io/en/stable/
BSD 2-Clause "Simplified" License
711 stars 167 forks source link

UX improvement: Displaying the rollback reason after stack goes into failed state #687

Closed GarisonLotus closed 5 years ago

GarisonLotus commented 5 years ago

This is something that's slightly bothered me for a while, but not enough for me to do something about it. I've always wanted stacker to display the reason for a roll back.

This PR includes a new function in the default provider that returns the rollback reason, which is now called via the build action when a failure occurs. Stacker will display the reason after either ROLLBACK_COMPLETE or UPDATE_ROLLBACK_COMPLETE.

Tested both creating a new stack that fails as well as updating a deployed stack with multiple rollback reasons due to more than one failed update to the same stack. Both show the latest event failure reason.

⇒  stacker build -i ./us-east-1.env ./create_failed_test.yaml -r us-east-1
[2018-12-06T19:41:28] Using interactive AWS provider mode.
The "cbdvxkjnkejcbs-error-test2" stack is in a failed state (ROLLBACK_COMPLETE).
It cannot be updated, but it can be deleted and re-created.
All its current resources will IRREVERSIBLY DESTROYED.
Proceed carefully!

Execute the above changes? [y/n] y
[2018-12-06T19:41:33] Destroying stack "cbdvxkjnkejcbs-error-test2" for re-creation
[2018-12-06T19:41:33] error-test2: submitted (destroying stack for re-creation)
[2018-12-06T19:41:36] cbdvxkjnkejcbs-error-test changes:
Parameters Modified: VpcId
Replacements:
- Modify SecurityGroup (AWS::EC2::SecurityGroup)
Execute the above changes? [y/n/v] y
[2018-12-06T19:41:37] error-test: submitted (updating existing stack)
[2018-12-06T19:42:05] error-test2: submitted (creating new stack)
[2018-12-06T19:42:08] cbdvxkjnkejcbs-error-test Stack Roll Back Reason: Parameter validation failed: parameter value vpc-garisonwi for parameter name VpcId does not exist
[2018-12-06T19:42:08] error-test: failed (updating existing stack)
[2018-12-06T19:42:35] cbdvxkjnkejcbs-error-test2 Stack Roll Back Reason: Parameter validation failed: parameter value vpc-c7d4adbh for parameter name VpcId does not exist. Rollback requested by user.
[2018-12-06T19:42:35] error-test2: failed (creating new stack)
[2018-12-06T19:42:35] The following steps failed: error-test, error-test2
russellballestrini commented 5 years ago

@GarisonLotus amazing this will save me from having to open the CloudFormation console on failures!

GarisonLotus commented 5 years ago

I'm looking into the two failing tests now.

GarisonLotus commented 5 years ago

@russellballestrini - I mocked sample event data in tests so they would pass with the new function.