SNS Lambda Subscription Conflict
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
When subscribing multiple SNS Topics to a single Lambda Function, if two of those Topics have the same `id` (scope-local - this could happen if those Topics are in different scopes) then the second subscription will fail to be created with:
```
A subscription with id "SomeId" already exists under the scope Stack/Resource
```
### Reproduction Steps
See [robwettach/sns-lambda-subscription-conflict](https://github.com/robwettach/sns-lambda-subscription-conflict)
### Error Log
```
A subscription with id "SomeId" already exists under the scope Stack/Resource
```
### Environment
- **CLI Version :** 1.37.0 (build e4709de)
- **Framework Version:** 1.37.0
- **OS :** macOS Mojave 10.14.6
- **Language :** TypeScript (all)
### Other
I believe changing [this line](https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-sns-subscriptions/lib/lambda.ts#L37) from
```
subscriberId: topic.node.id,
```
to
```
subscriberId: topic.node.uniqueId,
```
will solve this issue.
---
This is :bug: Bug Report
Contributor guide
Research direction
Start with packages/@aws-cdk/aws-sns-subscriptions/lib/lambda.ts and compare the subscriberId construction with the linked reproduction repository. Reproduce two SNS Topic subscriptions sharing the same scope-local id, then verify that both subscriptions can be created without the duplicate-id error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100