From 6c9f959b944b395bf1d1cfa05fe95d476573151c Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Wed, 27 Oct 2021 01:15:51 -0700 Subject: [PATCH] Set the appropriate SNS subject when sending CloudFormation stack events (#4479) --- moto/cloudformation/models.py | 4 +++- tests/test_cloudformation/test_cloudformation_stack_crud.py | 1 + .../test_cloudformation_stack_crud_boto3.py | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/moto/cloudformation/models.py b/moto/cloudformation/models.py index 69ddb168a..404817ad0 100644 --- a/moto/cloudformation/models.py +++ b/moto/cloudformation/models.py @@ -477,7 +477,9 @@ ClientRequestToken='{client_request_token}'""".format( ) for sns_topic_arn in sns_topic_arns: - sns_backends[region].publish(message, arn=sns_topic_arn) + sns_backends[region].publish( + message, subject="AWS CloudFormation Notification", arn=sns_topic_arn + ) def filter_stacks(all_stacks, status_filter): diff --git a/tests/test_cloudformation/test_cloudformation_stack_crud.py b/tests/test_cloudformation/test_cloudformation_stack_crud.py index 754875623..82086434b 100644 --- a/tests/test_cloudformation/test_cloudformation_stack_crud.py +++ b/tests/test_cloudformation/test_cloudformation_stack_crud.py @@ -209,6 +209,7 @@ def test_create_stack_with_notification_arn(): message = queue.read(1) msg = json.loads(message.get_body()) + msg["Subject"].should.equal("AWS CloudFormation Notification") msg["Message"].should.contain("StackId='{}'\n".format(stack.stack_id)) msg["Message"].should.contain("Timestamp='2015-01-01T12:00:00.000Z'\n") msg["Message"].should.contain("LogicalResourceId='test_stack_with_notifications'\n") diff --git a/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py b/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py index 402e3acff..7882384bb 100644 --- a/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py +++ b/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py @@ -1047,6 +1047,7 @@ def test_create_stack_with_notification_arn(): messages = queue.receive_messages() messages.should.have.length_of(1) msg = json.loads(messages[0].body) + msg["Subject"].should.equal("AWS CloudFormation Notification") msg["Message"].should.contain("StackId='{}'\n".format(stack.stack_id)) msg["Message"].should.contain("LogicalResourceId='test_stack_with_notifications'\n") msg["Message"].should.contain("ResourceStatus='CREATE_IN_PROGRESS'\n")