Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix how CloudFormation stack changes are detected #507

Merged
merged 5 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
minor_changes:
- cloudformation - fix detection when there are no changes.
Sometimes when there are no changes, the change set will have a status FAILED with StatusReason
No updates are to be performed.
(https://github.com/ansible-collections/amazon.aws/pull/507)
tremble marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 4 additions & 3 deletions plugins/modules/cloudformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ def create_changeset(module, stack_params, cfn, events_limit):
module.fail_json_aws(err)
if newcs['Status'] == 'CREATE_PENDING' or newcs['Status'] == 'CREATE_IN_PROGRESS':
time.sleep(1)
elif newcs['Status'] == 'FAILED' and "The submitted information didn't contain changes" in newcs['StatusReason']:
elif newcs['Status'] == 'FAILED' and ("The submitted information didn't contain changes" in newcs['StatusReason']
or "No updates are to be performed" in newcs['StatusReason']):
cfn.delete_change_set(aws_retry=True, ChangeSetName=cs['Id'])
result = dict(changed=False,
output='The created Change Set did not contain any changes to this stack and was deleted.')
Expand Down Expand Up @@ -594,8 +595,8 @@ def check_mode_changeset(module, stack_params, cfn):

reason = description.get('StatusReason')

if description['Status'] == 'FAILED' and "didn't contain changes" in description['StatusReason']:
return {'changed': False, 'msg': reason, 'meta': description['StatusReason']}
if description['Status'] == 'FAILED' and ("didn't contain changes" in reason or "No updates are to be performed" in reason):
return {'changed': False, 'msg': reason, 'meta': reason}
return {'changed': True, 'msg': reason, 'meta': description['Changes']}

except (botocore.exceptions.ValidationError, botocore.exceptions.ClientError) as err:
Expand Down