Kotaimen / awscfncli

Friendly AWS CloudFormation CLI
MIT License
59 stars 12 forks source link

Improve error message when `changestack create` fails when no changes #20

Closed mkielar closed 6 years ago

mkielar commented 6 years ago

When I run cfn changestack create on a simple stack (no nested stacks) and Cloudformation figures out there are no changes, it fails with:

Region: eu-west-2
Stack Name: dummy-stck
Template: C:\repositories\cloudformation\dummy-stack.yaml
Creating change set...
ChangeSet Name: mkitest1
ChangeSet ARN: arn:aws:cloudformation:eu-west-2:000000000000:changeSet/mkitest1/9189df70-92b0-49e3-97f7-d1fd173161b4
Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state
Aborted!

The thing is, that when I go to AWS Console => CloudFormation => dummy-stack => Change Sets => Click on mkitest1, I go into the change set details, and see the real reason for the failure, which is:

Status: FAILED - The submitted information didn't contain changes. Submit different information to create a change set.

I'd expect to see that error message returned by cfn, as currently there is no way of knowing if the changeset stack failed because of no changes, or because of something else...

mkielar commented 6 years ago

As a workaround, after cfn fails, I'm calling:

real_reason="$(aws cloudformation describe-change-set --change-set-name=${change_set_arn} --query 'StatusReason' --output text)"

if [[ "${real_reason}" = *"didn't contain changes"* ]]; then
    echo "No changes in change-set. Exiting."
    exit 0
else
    ...
Kotaimen commented 6 years ago

This is fixed in v2 branch's sync command, which will be released soon. However, because we dropped changeset command in new version, we'll try to do a back port. (sync combines changeset create and changeset execute and supports SAM.)