How to create SNS Subscription filter policy

2.1k views Asked by At

I'm trying to create SNS Subscription filter policy. I want this filter policy to send the message to user only when cloudformation Resource status is "CREATE_IN_PROGRESS" for s3 bucket and all the other cloudformation resource creation events shouldn't be sent to user. Can anyone with experience with creating SNS Subscription filter policy for Cloudformation events please assist on this.I just want user to receive only notification when ResourceStatus='CREATE_IN_PROGRESS' for ResourceType='AWS::S3::Bucket' and the bucket is Logical Resource Id='TestBucket'

'

1

There are 1 answers

0
John Rotenstein On

I don't think that will work.

From Amazon SNS subscription filter policies - Amazon Simple Notification Service:

A subscription filter policy allows you to specify attribute names and assign a list of values to each attribute name... Each attribute name in a filter policy matches an attribute name assigned to the message.

When AWS CloudFormation sends events, they are sent as a block of JSON. Individual elements (eg Status, Bucket name) are not sent as Amazon SNS Message Attributes. Thus, the rules will not be able to detect these values.

An alternative would be to write an AWS Lambda function that can parse the message and respond accordingly.