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

SNS: payload-based message filtering #23079

Closed
2 tasks done
brennanho opened this issue Nov 25, 2022 · 4 comments · Fixed by #23108
Closed
2 tasks done

SNS: payload-based message filtering #23079

brennanho opened this issue Nov 25, 2022 · 4 comments · Fixed by #23108
Assignees
Labels
@aws-cdk/aws-sns Related to Amazon Simple Notification Service effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1

Comments

@brennanho
Copy link
Contributor

Describe the feature

AWS introduced payload-based message filtering: https://aws.amazon.com/blogs/compute/introducing-payload-based-message-filtering-for-amazon-sns/. Would be awesome to see support for this in CDK.

Use Case

Filtering out messages by payload attributes. Often, SNS owners from away teams do not supply the sufficient message attributes to filter out messages. This change would allow SNS subscribers (SQS subscribing to SNS in my case) to filter messages regardless of whether the SNS owner has configured any message attributes.

Proposed Solution

Have the option to choose FilterPolicyScope when subscribing to an SNS topic i.e. either MessageBody or MessageAttributes. See: https://docs.aws.amazon.com/sns/latest/dg/sns-message-filtering.html. I was thinking to add filterPolicyScope to the SubscriptionFilter class and then being able to switch filterPolicyScope to either MessageBody or MessageAttributes.

Before:

  Topic.fromTopicArn(
      myStack,
      "myStackId",
      "arn:aws:sns:us-east-1:..."
  ).addSubscription(new SqsSubscription(myLambda.inputQueue, { filterPolicy: {...} }));

After:

  Topic.fromTopicArn(
      myStack,
      "myStackId",
      "arn:aws:sns:us-east-1:..."
  ).addSubscription(new SqsSubscription(myLambda.inputQueue, { filterPolicyScope: "MessageBody", filterPolicy: {...} }));

Other Information

Links

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.38.1 (aws-cdk-lib)

Environment details (OS name and version, etc.)

MacOS 12.3.1

@brennanho brennanho added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 25, 2022
@github-actions github-actions bot added the @aws-cdk/aws-sns Related to Amazon Simple Notification Service label Nov 25, 2022
@peterwoodworth peterwoodworth added p1 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Nov 26, 2022
@peterwoodworth
Copy link
Contributor

peterwoodworth commented Nov 26, 2022

Thanks for the request, it seems like CloudFormation support should be live already with this feature so we should be good to start working on it.

Edit: We need the CfnSpec to merge this update first before we can merge the PR. Thanks for the contribution!

@brennanho
Copy link
Contributor Author

Thanks for the request, it seems like CloudFormation support should be live already with this feature so we should be good to start working on it.

I can create a PR for this if the effort is small. Do you know where the changes would need to be made?

@brennanho brennanho changed the title SNS/SQS: payload-based message filtering SNS: payload-based message filtering Nov 27, 2022
@brennanho
Copy link
Contributor Author

PR: #23108

@mergify mergify bot closed this as completed in #23108 Feb 24, 2023
mergify bot pushed a commit that referenced this issue Feb 24, 2023
----
closes #23079 

### Description
This PR adds support for FilterPolicyScope for SNS subscriptions. This is in response to AWS introducing payload-based message filtering: https://aws.amazon.com/blogs/compute/introducing-payload-based-message-filtering-for-amazon-sns/.

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

beck3905 pushed a commit to beck3905/aws-cdk that referenced this issue Feb 28, 2023
----
closes aws#23079 

### Description
This PR adds support for FilterPolicyScope for SNS subscriptions. This is in response to AWS introducing payload-based message filtering: https://aws.amazon.com/blogs/compute/introducing-payload-based-message-filtering-for-amazon-sns/.

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
homakk pushed a commit to homakk/aws-cdk that referenced this issue Mar 28, 2023
----
closes aws#23079 

### Description
This PR adds support for FilterPolicyScope for SNS subscriptions. This is in response to AWS introducing payload-based message filtering: https://aws.amazon.com/blogs/compute/introducing-payload-based-message-filtering-for-amazon-sns/.

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-sns Related to Amazon Simple Notification Service effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants