Skip to content

Commit a75f447

Browse files
authored
feat(sns): enforce ssl with topic policy (#29144)
Adds a statement to match the document in the [docs](https://docs.aws.amazon.com/sns/latest/dg/sns-security-best-practices.html#enforce-encryption-data-in-transit): ``` { "Id": "ExamplePolicy", "Version": "2012-10-17", "Statement": [ { "Sid": "AllowPublishThroughSSLOnly", "Action": "SNS:Publish", "Effect": "Deny", "Resource": [ "arn:aws:sns:us-east-1:1234567890:test-topic" ], "Condition": { "Bool": { "aws:SecureTransport": "false" } }, "Principal": "*" } ] } ``` Closes #29142. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 1fd5485 commit a75f447

14 files changed

+861
-3
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-sns/test/integ.sns-topic-policy.js.snapshot/SNSTopicPolicyIntegDefaultTestDeployAssert005CA6BA.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-sns/test/integ.sns-topic-policy.js.snapshot/SNSTopicPolicyIntegDefaultTestDeployAssert005CA6BA.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-sns/test/integ.sns-topic-policy.js.snapshot/SNSTopicPolicyStack.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
{
2+
"Resources": {
3+
"TopicBFC7AF6E": {
4+
"Type": "AWS::SNS::Topic",
5+
"Properties": {
6+
"DisplayName": "fooDisplay",
7+
"TopicName": "fooTopic"
8+
}
9+
},
10+
"TopicPolicyA24B096F": {
11+
"Type": "AWS::SNS::TopicPolicy",
12+
"Properties": {
13+
"PolicyDocument": {
14+
"Statement": [
15+
{
16+
"Action": "sns:Publish",
17+
"Effect": "Allow",
18+
"Principal": {
19+
"Service": "s3.amazonaws.com"
20+
},
21+
"Resource": {
22+
"Ref": "TopicBFC7AF6E"
23+
},
24+
"Sid": "0"
25+
},
26+
{
27+
"Action": "sns:Publish",
28+
"Condition": {
29+
"Bool": {
30+
"aws:SecureTransport": "false"
31+
}
32+
},
33+
"Effect": "Deny",
34+
"Principal": "*",
35+
"Resource": {
36+
"Ref": "TopicBFC7AF6E"
37+
},
38+
"Sid": "AllowPublishThroughSSLOnly"
39+
}
40+
],
41+
"Version": "2012-10-17"
42+
},
43+
"Topics": [
44+
{
45+
"Ref": "TopicBFC7AF6E"
46+
}
47+
]
48+
}
49+
},
50+
"TopicAddPolicy7DB03706": {
51+
"Type": "AWS::SNS::Topic",
52+
"Properties": {
53+
"DisplayName": "topicDisplayNameAddPolicy",
54+
"TopicName": "topicAddPolicy"
55+
}
56+
},
57+
"TopicAddPolicyAEA24A5A": {
58+
"Type": "AWS::SNS::TopicPolicy",
59+
"Properties": {
60+
"PolicyDocument": {
61+
"Statement": [
62+
{
63+
"Action": "sns:Publish",
64+
"Effect": "Allow",
65+
"Principal": {
66+
"Service": "s3.amazonaws.com"
67+
},
68+
"Resource": {
69+
"Ref": "TopicAddPolicy7DB03706"
70+
},
71+
"Sid": "0"
72+
},
73+
{
74+
"Action": "sns:Publish",
75+
"Condition": {
76+
"Bool": {
77+
"aws:SecureTransport": "false"
78+
}
79+
},
80+
"Effect": "Deny",
81+
"Principal": "*",
82+
"Resource": {
83+
"Ref": "TopicAddPolicy7DB03706"
84+
},
85+
"Sid": "AllowPublishThroughSSLOnly"
86+
}
87+
],
88+
"Version": "2012-10-17"
89+
},
90+
"Topics": [
91+
{
92+
"Ref": "TopicAddPolicy7DB03706"
93+
}
94+
]
95+
}
96+
}
97+
},
98+
"Parameters": {
99+
"BootstrapVersion": {
100+
"Type": "AWS::SSM::Parameter::Value<String>",
101+
"Default": "/cdk-bootstrap/hnb659fds/version",
102+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
103+
}
104+
},
105+
"Rules": {
106+
"CheckBootstrapVersion": {
107+
"Assertions": [
108+
{
109+
"Assert": {
110+
"Fn::Not": [
111+
{
112+
"Fn::Contains": [
113+
[
114+
"1",
115+
"2",
116+
"3",
117+
"4",
118+
"5"
119+
],
120+
{
121+
"Ref": "BootstrapVersion"
122+
}
123+
]
124+
}
125+
]
126+
},
127+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
128+
}
129+
]
130+
}
131+
}
132+
}

packages/@aws-cdk-testing/framework-integ/test/aws-sns/test/integ.sns-topic-policy.js.snapshot/cdk.out

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-sns/test/integ.sns-topic-policy.js.snapshot/integ.json

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-sns/test/integ.sns-topic-policy.js.snapshot/manifest.json

+131
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)