mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 05:40:23 -07:00
CloudFormation module: get StackEvents when ClientRequestToken is not used (#32434)
* When getting the stack events we need to consider the case where we don't have ClientRequestToken fixes #32396 * Adding tests for the case when the ClientRequestToken is not present in the stack creation. * Renaming the stack that the test for Client Request Token requires so it won't cause collisions with the basic test.
This commit is contained in:
parent
43914b3837
commit
67b1d0f274
25 changed files with 935 additions and 29 deletions
|
@ -256,7 +256,7 @@ def get_stack_events(cfn, stack_name, token_filter=None):
|
|||
"StackEvents[?ClientRequestToken == '{0}']".format(token_filter)
|
||||
))
|
||||
else:
|
||||
events = list(pg)
|
||||
events = list(pg.search("StackEvents[*]"))
|
||||
except (botocore.exceptions.ValidationError, botocore.exceptions.ClientError) as err:
|
||||
error_msg = boto_exception(err)
|
||||
if 'does not exist' in error_msg:
|
||||
|
@ -292,7 +292,7 @@ def create_stack(module, stack_params, cfn):
|
|||
|
||||
try:
|
||||
cfn.create_stack(**stack_params)
|
||||
result = stack_operation(cfn, stack_params['StackName'], 'CREATE', stack_params['ClientRequestToken'])
|
||||
result = stack_operation(cfn, stack_params['StackName'], 'CREATE', stack_params.get('ClientRequestToken', None))
|
||||
except Exception as err:
|
||||
error_msg = boto_exception(err)
|
||||
module.fail_json(msg="Failed to create stack {0}: {1}.".format(stack_params.get('StackName'), error_msg), exception=traceback.format_exc())
|
||||
|
@ -351,7 +351,7 @@ def update_stack(module, stack_params, cfn):
|
|||
# don't need to be updated.
|
||||
try:
|
||||
cfn.update_stack(**stack_params)
|
||||
result = stack_operation(cfn, stack_params['StackName'], 'UPDATE', stack_params['ClientRequestToken'])
|
||||
result = stack_operation(cfn, stack_params['StackName'], 'UPDATE', stack_params.get('ClientRequestToken', None))
|
||||
except Exception as err:
|
||||
error_msg = boto_exception(err)
|
||||
if 'No updates are to be performed.' in error_msg:
|
||||
|
@ -630,7 +630,7 @@ def main():
|
|||
result = {'changed': False, 'output': 'Stack not found.'}
|
||||
else:
|
||||
cfn.delete_stack(StackName=stack_params['StackName'])
|
||||
result = stack_operation(cfn, stack_params['StackName'], 'DELETE', stack_params['ClientRequestToken'])
|
||||
result = stack_operation(cfn, stack_params['StackName'], 'DELETE', stack_params.get('ClientRequestToken', None))
|
||||
except Exception as err:
|
||||
module.fail_json(msg=boto_exception(err), exception=traceback.format_exc())
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue