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

aws-sns: 'autoCreatePolicy' for the imported topic is set to false, #21158

Closed
2 tasks
gokendra1 opened this issue Jul 15, 2022 · 3 comments
Closed
2 tasks

aws-sns: 'autoCreatePolicy' for the imported topic is set to false, #21158

gokendra1 opened this issue Jul 15, 2022 · 3 comments
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. good first issue Related to contributions. See CONTRIBUTING.md p2

Comments

@gokendra1
Copy link

Describe the feature

Since the 'autoCreatePolicy' for the imported topic is set to false by default, Hence we need to add the policy explicitly.

Use Case

The basic requirement is that I have an SNS Topic created in one App (Core App) and I need to access it in another App (Jobs App).
I have one stack per app.

The issue is:

  1. If I use ITopic in Jobs app, CDK does not update the access policy of the SNS Topic to allow Event bridge to put a message.
  2. If I acess the Core App and then its SNS Topic in Jobs app (both in Java), I get the error message that 'Cannot reference across apps. Consuming and producing stacks must be defined within the same CDK app.'

Proposed Solution

If possible make the property 'autoCreatePolicy' configurable or allow user to set it to true/false as per the use case.

Other Information

No response

Acknowledgements

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

CDK version used

2.31.2

Environment details (OS name and version, etc.)

macOS 12.3.1

@gokendra1 gokendra1 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 15, 2022
@github-actions github-actions bot added the @aws-cdk/aws-sns Related to Amazon Simple Notification Service label Jul 15, 2022
@peterwoodworth peterwoodworth added good first issue Related to contributions. See CONTRIBUTING.md p2 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 Jul 28, 2022
@peterwoodworth
Copy link
Contributor

peterwoodworth commented Jul 28, 2022

I think we should be able to support this, as the arn is the only information required to be able to create a new TopicPolicy. Would need a new method fromTopicAttributes

You can also just pass your imported topic to a new TopicPolicy, as that's all this prop is doing under the hood. https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-sns.TopicPolicy.html

We may want to clarify this in the docs instead of adjusting the current implementation

@kaizencc kaizencc removed their assignment Aug 18, 2022
@SankyRed SankyRed self-assigned this Jul 24, 2023
@rix0rrr
Copy link
Contributor

rix0rrr commented Aug 7, 2023

It's not safe to add an AWS::SNS::TopicPolicy to referenced Topics (that is to say, AWS::SNS::Topic and AWS::SNS::TopicPolicy must be in the same Stack, and the only way to guarantee that is to have access to a Topic class, not an ITopic interface).

Your problem might be with the definition of your CDK app. If you put all your Stacks into the same App, it should work as intended. If you can't do that, you will need to find a way for the Core App to know about all the policies it needs in advance, and add them there.

@rix0rrr rix0rrr closed this as completed Aug 7, 2023
@github-actions
Copy link

github-actions bot commented Aug 7, 2023

⚠️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.

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. good first issue Related to contributions. See CONTRIBUTING.md p2
Projects
None yet
Development

No branches or pull requests

5 participants