Using a single lambda function for multiple SNS triggers
- Dominant language
- Python
- Stars
- 11.1k
- Forks
- 1k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 2
Description
Hi,
We have a use case for lambda function to send some metrics about files being uploaded to S3 to a monitoring server. There are multiple SNS topics which receives events from S3 buckets. For example, TopicA receives notification for S3 when a file is created under BucketA/folder1 and TopicB receives notification when a file is created under BucketB/folder1, etc. The lambda function that we would like to create is a generic function which can read the message from the event and take appropriate actions. Is there a way to have a single lambda function subscribe to multiple SNS topics?
Right now, I can only think of the below approach, which deploys multiple lambda functions(one per sns topic)
@app.on_sns_message(topic='SNSTest1')
def handle_SNSTest(event):
process_sns_message(event)
@app.on_sns_message(topic='SNSTest2')
def handle_SNSTest2(event):
process_sns_message(event)
@app.on_sns_message(topic='SNSTest3')
def handle_SNSTest3(event):
process_sns_message(event)
Is there a better way to write this?
Thanks
Contributor guide
Research direction
Start by reading the @app.on_sns_message examples and the shared process_sns_message entry point shown in the issue, then trace how Chalice represents SNS subscriptions. Compare the requested multi-topic use case with the current trigger model; done means the supported approach or a clearly scoped change is established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- backend, cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100