SNS Topic Policy can't be created and synth'd
See original GitHub issue❓ General Issue
When creating an SNS TopicPolicy the Props only have topics
as a field. However, there also needs to be a PolicyDocument field and without it an error occurs during synth. There doesn’t appear to be any way to set it, either through the Props in the constructor or after the fact.
The Question
With this minimum example:
const topic = new Topic(this, 'topic', {});
const tp = new TopicPolicy(this, 'tp', {
topics: [topic],
});
An error occurs during synth:
Error: Resolution error: Supplied properties not correct for "CfnTopicPolicyProps"
policyDocument: required but missing.
Environment
- CDK CLI Version: 1.38.0 (build d5fa31f)
- Module Version: 1.38.0
- OS: Mac OS 10.15.4
- Language: Typescript
Other information
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Edit an Amazon SNS topic's access policy
To edit your Amazon SNS topic's access policy using the Amazon SNS console ... 1. Open the Amazon SNS console. 2. In the...
Read more >SNS to Lambda - Serverless Land
This pattern contains a sample AWS CDK stack to create a Lambda Function, a SNS Topic and the IAM permissions required to run...
Read more >cdk synth | AWS CDK Workshop
To synthesize a CDK app, use the cdk synth command. ... Type: AWS::SNS::Topic Properties: DisplayName: My First Topic Yeah Metadata: aws:cdk:path: ...
Read more >Cdk use existing vpc - Seba Online
I am creating SNS topic and HTTPS subscription using CDK and want to provide custom delivery retry policy. We are a leading provider...
Read more >How to install AWS CDK (step-by-step guide)
To create an AWS CDK project you can initialize it using the cdk init ... an Amazon SQS queue that is subscribed to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So after spending some time researching this and talking to @rix0rrr, I think that the correct usage here is to use
addStatements
to add statements to the policy document post construction. You shouldn’t be synthesizing an empty policy document, and CFN won’t let you deploy one anyway. Here is a short example:General I’d recommend using
addToResourcePolicy
over creating aTopicPolicy
but the above allows synthesizing one.Hi @mbonig, sorry for the late reply. It does seem like this is a bug, I’m getting the same error. So I’ll file this as a bug and we’ll add it to our workload. In the meantime, you might want to try using
Topic.addToResourcePolicy(statement)
instead ofTopicPolicy
.