Encountering an issue when attempting to reference all SNS actions with * in CDK.
const MyTopicPolicy = new sns.TopicPolicy(this, 'MyTopicSNSPolicy', {
topics: [MyTopic],
});
MyTopicPolicy.document.addStatements(new iam.PolicyStatement({
sid: "0",
actions: ["sns:*"],
principals: [new iam.AnyPrincipal()]
resources: [MyTopic.topicArn],
conditions: {"StringEquals": {"AWS:SourceOwner":"1212121212"}},
}));
Upon running cdk synth, the generated snippet in the template is as follows:
"MyTopicSNSPolicyE244CE5D": {
"Type": "AWS::SNS::TopicPolicy",
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": "SNS:*",
"Condition": {
"StringEquals": {
"AWS:SourceOwner": "1212121212"
}
},
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Resource": {
"Ref": "MyTopic62D646CB"
},
"Sid": "0"
}
],
However, during the cloudformation build process, an error is encountered in the Events section:
Invalid parameter: Policy statement action out of service scope! (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter