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.
pull/32511/head
Jonathan Nuñez 7 years ago committed by Ryan Brown
parent 43914b3837
commit 67b1d0f274

@ -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())

@ -20,7 +20,6 @@
"ResourceStatusReason": "User Initiated",
"StackName": "ansible-test-basic-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-basic-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-basic-yaml"
}
],

@ -21,7 +21,6 @@
"StackName": "ansible-test-basic-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-basic-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
@ -42,7 +41,6 @@
"StackName": "ansible-test-basic-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
@ -63,7 +61,6 @@
"ResourceStatusReason": "User Initiated",
"StackName": "ansible-test-basic-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-basic-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-basic-yaml"
}
],

@ -21,7 +21,6 @@
"StackName": "ansible-test-basic-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-basic-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
@ -42,7 +41,6 @@
"StackName": "ansible-test-basic-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
@ -63,7 +61,6 @@
"ResourceStatusReason": "User Initiated",
"StackName": "ansible-test-basic-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-basic-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-basic-yaml"
}
],

@ -21,7 +21,6 @@
"StackName": "ansible-test-basic-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-basic-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
@ -42,7 +41,6 @@
"StackName": "ansible-test-basic-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
@ -63,7 +61,6 @@
"ResourceStatusReason": "User Initiated",
"StackName": "ansible-test-basic-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-basic-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-basic-yaml"
}
],

@ -21,7 +21,6 @@
"StackName": "ansible-test-basic-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-basic-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
@ -42,7 +41,6 @@
"StackName": "ansible-test-basic-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
@ -63,7 +61,6 @@
"ResourceStatusReason": "User Initiated",
"StackName": "ansible-test-basic-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-basic-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-basic-yaml"
}
],

@ -20,7 +20,6 @@
"StackName": "ansible-test-basic-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-basic-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
@ -42,7 +41,6 @@
"StackName": "ansible-test-basic-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-basic-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
@ -63,7 +61,6 @@
"StackName": "ansible-test-basic-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
@ -84,7 +81,6 @@
"ResourceStatusReason": "User Initiated",
"StackName": "ansible-test-basic-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-basic-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-basic-yaml"
}
],

@ -19,7 +19,6 @@
},
"StackName": "ansible-test-basic-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-basic-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-basic-yaml"
},
{
@ -40,7 +39,6 @@
"StackName": "ansible-test-basic-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-basic-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
@ -62,7 +60,6 @@
"StackName": "ansible-test-basic-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-basic-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
@ -83,7 +80,6 @@
"StackName": "ansible-test-basic-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
@ -104,7 +100,6 @@
"ResourceStatusReason": "User Initiated",
"StackName": "ansible-test-basic-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-basic-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-basic-yaml"
}
],

@ -0,0 +1,17 @@
{
"status_code": 200,
"data": {
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "03fbfc36-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "03fbfc36-b5d0-11e7-ae09-550cfe4b2358",
"date": "Fri, 20 Oct 2017 19:51:07 GMT",
"content-length": "393",
"content-type": "text/xml"
}
}
}
}

@ -0,0 +1,16 @@
{
"status_code": 200,
"data": {
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "170d1e02-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "170d1e02-b5d0-11e7-ae09-550cfe4b2358",
"date": "Fri, 20 Oct 2017 19:51:39 GMT",
"content-length": "212",
"content-type": "text/xml"
}
}
}
}

@ -0,0 +1,39 @@
{
"status_code": 200,
"data": {
"StackEvents": [
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "04032730-b5d0-11e7-86b8-503ac93168c5",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::CloudFormation::Stack",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 8,
"microsecond": 324000,
"year": 2017,
"day": 20,
"minute": 51
},
"ResourceStatusReason": "User Initiated",
"StackName": "ansible-test-client-request-token-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-client-request-token-yaml"
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "043d4a05-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "043d4a05-b5d0-11e7-ae09-550cfe4b2358",
"date": "Fri, 20 Oct 2017 19:51:08 GMT",
"content-length": "1183",
"content-type": "text/xml"
}
}
}
}

@ -0,0 +1,83 @@
{
"status_code": 200,
"data": {
"StackEvents": [
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "MyBucket-CREATE_IN_PROGRESS-2017-10-20T19:51:12.754Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::S3::Bucket",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 12,
"microsecond": 754000,
"year": 2017,
"day": 20,
"minute": 51
},
"ResourceStatusReason": "Resource creation Initiated",
"StackName": "ansible-test-client-request-token-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-client-request-token-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "MyBucket-CREATE_IN_PROGRESS-2017-10-20T19:51:11.159Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::S3::Bucket",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 11,
"microsecond": 159000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "04032730-b5d0-11e7-86b8-503ac93168c5",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::CloudFormation::Stack",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 8,
"microsecond": 324000,
"year": 2017,
"day": 20,
"minute": 51
},
"ResourceStatusReason": "User Initiated",
"StackName": "ansible-test-client-request-token-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-client-request-token-yaml"
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "075d9d71-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "075d9d71-b5d0-11e7-ae09-550cfe4b2358",
"vary": "Accept-Encoding",
"content-length": "2730",
"content-type": "text/xml",
"date": "Fri, 20 Oct 2017 19:51:13 GMT"
}
}
}
}

@ -0,0 +1,83 @@
{
"status_code": 200,
"data": {
"StackEvents": [
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "MyBucket-CREATE_IN_PROGRESS-2017-10-20T19:51:12.754Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::S3::Bucket",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 12,
"microsecond": 754000,
"year": 2017,
"day": 20,
"minute": 51
},
"ResourceStatusReason": "Resource creation Initiated",
"StackName": "ansible-test-client-request-token-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-client-request-token-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "MyBucket-CREATE_IN_PROGRESS-2017-10-20T19:51:11.159Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::S3::Bucket",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 11,
"microsecond": 159000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "04032730-b5d0-11e7-86b8-503ac93168c5",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::CloudFormation::Stack",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 8,
"microsecond": 324000,
"year": 2017,
"day": 20,
"minute": 51
},
"ResourceStatusReason": "User Initiated",
"StackName": "ansible-test-client-request-token-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-client-request-token-yaml"
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "0a7eb31b-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "0a7eb31b-b5d0-11e7-ae09-550cfe4b2358",
"vary": "Accept-Encoding",
"content-length": "2730",
"content-type": "text/xml",
"date": "Fri, 20 Oct 2017 19:51:19 GMT"
}
}
}
}

@ -0,0 +1,83 @@
{
"status_code": 200,
"data": {
"StackEvents": [
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "MyBucket-CREATE_IN_PROGRESS-2017-10-20T19:51:12.754Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::S3::Bucket",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 12,
"microsecond": 754000,
"year": 2017,
"day": 20,
"minute": 51
},
"ResourceStatusReason": "Resource creation Initiated",
"StackName": "ansible-test-client-request-token-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-client-request-token-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "MyBucket-CREATE_IN_PROGRESS-2017-10-20T19:51:11.159Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::S3::Bucket",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 11,
"microsecond": 159000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "04032730-b5d0-11e7-86b8-503ac93168c5",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::CloudFormation::Stack",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 8,
"microsecond": 324000,
"year": 2017,
"day": 20,
"minute": 51
},
"ResourceStatusReason": "User Initiated",
"StackName": "ansible-test-client-request-token-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-client-request-token-yaml"
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "0d9e1c06-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "0d9e1c06-b5d0-11e7-ae09-550cfe4b2358",
"vary": "Accept-Encoding",
"content-length": "2730",
"content-type": "text/xml",
"date": "Fri, 20 Oct 2017 19:51:24 GMT"
}
}
}
}

@ -0,0 +1,83 @@
{
"status_code": 200,
"data": {
"StackEvents": [
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "MyBucket-CREATE_IN_PROGRESS-2017-10-20T19:51:12.754Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::S3::Bucket",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 12,
"microsecond": 754000,
"year": 2017,
"day": 20,
"minute": 51
},
"ResourceStatusReason": "Resource creation Initiated",
"StackName": "ansible-test-client-request-token-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-client-request-token-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "MyBucket-CREATE_IN_PROGRESS-2017-10-20T19:51:11.159Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::S3::Bucket",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 11,
"microsecond": 159000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "04032730-b5d0-11e7-86b8-503ac93168c5",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::CloudFormation::Stack",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 8,
"microsecond": 324000,
"year": 2017,
"day": 20,
"minute": 51
},
"ResourceStatusReason": "User Initiated",
"StackName": "ansible-test-client-request-token-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-client-request-token-yaml"
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "10bd84ca-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "10bd84ca-b5d0-11e7-ae09-550cfe4b2358",
"vary": "Accept-Encoding",
"content-length": "2730",
"content-type": "text/xml",
"date": "Fri, 20 Oct 2017 19:51:29 GMT"
}
}
}
}

@ -0,0 +1,104 @@
{
"status_code": 200,
"data": {
"StackEvents": [
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "MyBucket-CREATE_COMPLETE-2017-10-20T19:51:33.200Z",
"ResourceStatus": "CREATE_COMPLETE",
"ResourceType": "AWS::S3::Bucket",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 33,
"microsecond": 200000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-client-request-token-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "MyBucket-CREATE_IN_PROGRESS-2017-10-20T19:51:12.754Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::S3::Bucket",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 12,
"microsecond": 754000,
"year": 2017,
"day": 20,
"minute": 51
},
"ResourceStatusReason": "Resource creation Initiated",
"StackName": "ansible-test-client-request-token-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-client-request-token-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "MyBucket-CREATE_IN_PROGRESS-2017-10-20T19:51:11.159Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::S3::Bucket",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 11,
"microsecond": 159000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "04032730-b5d0-11e7-86b8-503ac93168c5",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::CloudFormation::Stack",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 8,
"microsecond": 324000,
"year": 2017,
"day": 20,
"minute": 51
},
"ResourceStatusReason": "User Initiated",
"StackName": "ansible-test-client-request-token-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-client-request-token-yaml"
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "13dbb3fd-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "13dbb3fd-b5d0-11e7-ae09-550cfe4b2358",
"vary": "Accept-Encoding",
"content-length": "3490",
"content-type": "text/xml",
"date": "Fri, 20 Oct 2017 19:51:34 GMT"
}
}
}
}

@ -0,0 +1,124 @@
{
"status_code": 200,
"data": {
"StackEvents": [
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "140d7220-b5d0-11e7-933f-50a686be7356",
"ResourceStatus": "CREATE_COMPLETE",
"ResourceType": "AWS::CloudFormation::Stack",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 35,
"microsecond": 121000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-client-request-token-yaml"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "MyBucket-CREATE_COMPLETE-2017-10-20T19:51:33.200Z",
"ResourceStatus": "CREATE_COMPLETE",
"ResourceType": "AWS::S3::Bucket",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 33,
"microsecond": 200000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-client-request-token-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "MyBucket-CREATE_IN_PROGRESS-2017-10-20T19:51:12.754Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::S3::Bucket",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 12,
"microsecond": 754000,
"year": 2017,
"day": 20,
"minute": 51
},
"ResourceStatusReason": "Resource creation Initiated",
"StackName": "ansible-test-client-request-token-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "ansible-test-client-request-token-yaml-mybucket-13m2y4v8bptj4",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "MyBucket-CREATE_IN_PROGRESS-2017-10-20T19:51:11.159Z",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::S3::Bucket",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 11,
"microsecond": 159000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"ResourceProperties": "{}\n",
"PhysicalResourceId": "",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "MyBucket"
},
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EventId": "04032730-b5d0-11e7-86b8-503ac93168c5",
"ResourceStatus": "CREATE_IN_PROGRESS",
"ResourceType": "AWS::CloudFormation::Stack",
"Timestamp": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 8,
"microsecond": 324000,
"year": 2017,
"day": 20,
"minute": 51
},
"ResourceStatusReason": "User Initiated",
"StackName": "ansible-test-client-request-token-yaml",
"PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"ClientRequestToken": "3faf3fb5-b289-41fc-b940-44151828f6cf",
"LogicalResourceId": "ansible-test-client-request-token-yaml"
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "16faf590-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "16faf590-b5d0-11e7-ae09-550cfe4b2358",
"vary": "Accept-Encoding",
"content-length": "4276",
"content-type": "text/xml",
"date": "Fri, 20 Oct 2017 19:51:39 GMT"
}
}
}
}

@ -0,0 +1,40 @@
{
"status_code": 200,
"data": {
"Stacks": [
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"EnableTerminationProtection": false,
"Description": "Basic template that creates an S3 bucket",
"Tags": [],
"StackStatusReason": "User Initiated",
"CreationTime": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 8,
"microsecond": 324000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"NotificationARNs": [],
"StackStatus": "CREATE_IN_PROGRESS",
"DisableRollback": false,
"RollbackConfiguration": {}
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "042974db-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "042974db-b5d0-11e7-ae09-550cfe4b2358",
"date": "Fri, 20 Oct 2017 19:51:08 GMT",
"content-length": "975",
"content-type": "text/xml"
}
}
}
}

@ -0,0 +1,39 @@
{
"status_code": 200,
"data": {
"Stacks": [
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"Description": "Basic template that creates an S3 bucket",
"Tags": [],
"EnableTerminationProtection": false,
"CreationTime": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 8,
"microsecond": 324000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"NotificationARNs": [],
"StackStatus": "CREATE_IN_PROGRESS",
"DisableRollback": false,
"RollbackConfiguration": {}
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "074b26dc-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "074b26dc-b5d0-11e7-ae09-550cfe4b2358",
"date": "Fri, 20 Oct 2017 19:51:13 GMT",
"content-length": "913",
"content-type": "text/xml"
}
}
}
}

@ -0,0 +1,39 @@
{
"status_code": 200,
"data": {
"Stacks": [
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"Description": "Basic template that creates an S3 bucket",
"Tags": [],
"EnableTerminationProtection": false,
"CreationTime": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 8,
"microsecond": 324000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"NotificationARNs": [],
"StackStatus": "CREATE_IN_PROGRESS",
"DisableRollback": false,
"RollbackConfiguration": {}
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "0a6cb1b3-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "0a6cb1b3-b5d0-11e7-ae09-550cfe4b2358",
"date": "Fri, 20 Oct 2017 19:51:18 GMT",
"content-length": "913",
"content-type": "text/xml"
}
}
}
}

@ -0,0 +1,39 @@
{
"status_code": 200,
"data": {
"Stacks": [
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"Description": "Basic template that creates an S3 bucket",
"Tags": [],
"EnableTerminationProtection": false,
"CreationTime": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 8,
"microsecond": 324000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"NotificationARNs": [],
"StackStatus": "CREATE_IN_PROGRESS",
"DisableRollback": false,
"RollbackConfiguration": {}
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "0d8cddf1-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "0d8cddf1-b5d0-11e7-ae09-550cfe4b2358",
"date": "Fri, 20 Oct 2017 19:51:23 GMT",
"content-length": "913",
"content-type": "text/xml"
}
}
}
}

@ -0,0 +1,39 @@
{
"status_code": 200,
"data": {
"Stacks": [
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"Description": "Basic template that creates an S3 bucket",
"Tags": [],
"EnableTerminationProtection": false,
"CreationTime": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 8,
"microsecond": 324000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"NotificationARNs": [],
"StackStatus": "CREATE_IN_PROGRESS",
"DisableRollback": false,
"RollbackConfiguration": {}
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "10ac94d5-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "10ac94d5-b5d0-11e7-ae09-550cfe4b2358",
"date": "Fri, 20 Oct 2017 19:51:28 GMT",
"content-length": "913",
"content-type": "text/xml"
}
}
}
}

@ -0,0 +1,39 @@
{
"status_code": 200,
"data": {
"Stacks": [
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"Description": "Basic template that creates an S3 bucket",
"Tags": [],
"EnableTerminationProtection": false,
"CreationTime": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 8,
"microsecond": 324000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"NotificationARNs": [],
"StackStatus": "CREATE_IN_PROGRESS",
"DisableRollback": false,
"RollbackConfiguration": {}
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "13caeb1b-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "13caeb1b-b5d0-11e7-ae09-550cfe4b2358",
"date": "Fri, 20 Oct 2017 19:51:33 GMT",
"content-length": "913",
"content-type": "text/xml"
}
}
}
}

@ -0,0 +1,45 @@
{
"status_code": 200,
"data": {
"Stacks": [
{
"StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/ansible-test-client-request-token-yaml/04023cd0-b5d0-11e7-86b8-503ac93168c5",
"Description": "Basic template that creates an S3 bucket",
"Tags": [],
"Outputs": [
{
"OutputKey": "TheName",
"OutputValue": "ansible-test-client-request-token-yaml-mybucket-13m2y4v8bptj4"
}
],
"EnableTerminationProtection": false,
"CreationTime": {
"hour": 19,
"__class__": "datetime",
"month": 10,
"second": 8,
"microsecond": 324000,
"year": 2017,
"day": 20,
"minute": 51
},
"StackName": "ansible-test-client-request-token-yaml",
"NotificationARNs": [],
"StackStatus": "CREATE_COMPLETE",
"DisableRollback": false,
"RollbackConfiguration": {}
}
],
"ResponseMetadata": {
"RetryAttempts": 0,
"HTTPStatusCode": 200,
"RequestId": "16ea53bb-b5d0-11e7-ae09-550cfe4b2358",
"HTTPHeaders": {
"x-amzn-requestid": "16ea53bb-b5d0-11e7-ae09-550cfe4b2358",
"date": "Fri, 20 Oct 2017 19:51:39 GMT",
"content-length": "1115",
"content-type": "text/xml"
}
}
}
}

@ -18,7 +18,7 @@
import pytest
from mock import patch
from . placebo_fixtures import placeboify, maybe_sleep
from .placebo_fixtures import placeboify, maybe_sleep
from ansible.modules.cloud.amazon import cloudformation as cfn_module
basic_yaml_tpl = """
@ -73,10 +73,10 @@ def test_invalid_template_json(placeboify):
assert "ValidationError" in m.exit_kwargs['msg']
def test_basic_s3_stack(maybe_sleep, placeboify):
def test_client_request_token_s3_stack(maybe_sleep, placeboify):
connection = placeboify.client('cloudformation')
params = {
'StackName': 'ansible-test-basic-yaml',
'StackName': 'ansible-test-client-request-token-yaml',
'TemplateBody': basic_yaml_tpl,
'ClientRequestToken': '3faf3fb5-b289-41fc-b940-44151828f6cf',
}
@ -87,6 +87,22 @@ def test_basic_s3_stack(maybe_sleep, placeboify):
# require that the final recorded stack state was CREATE_COMPLETE
# events are retrieved newest-first, so 0 is the latest
assert 'CREATE_COMPLETE' in result['events'][0]
connection.delete_stack(StackName='ansible-test-client-request-token-yaml')
def test_basic_s3_stack(maybe_sleep, placeboify):
connection = placeboify.client('cloudformation')
params = {
'StackName': 'ansible-test-basic-yaml',
'TemplateBody': basic_yaml_tpl
}
m = FakeModule(disable_rollback=False)
result = cfn_module.create_stack(m, params, connection)
assert result['changed']
assert len(result['events']) > 1
# require that the final recorded stack state was CREATE_COMPLETE
# events are retrieved newest-first, so 0 is the latest
assert 'CREATE_COMPLETE' in result['events'][0]
connection.delete_stack(StackName='ansible-test-basic-yaml')

Loading…
Cancel
Save