Skip to content

Commit

Permalink
fix(sns): topic policy is not created even if enforceSSL enabled (#31569
Browse files Browse the repository at this point in the history
)

### Issue # (if applicable)

Closes #31558.

### Reason for this change

<!--What is the bug or use case behind this change?-->

SNS topic policy is not created even if `enforceSSL` is enabled, until
calling `addToResourcePolicy` method.

But, originally, the policy should be created without calling the
`addToResourcePolicy` method.

### Description of changes

<!--What code changes did you make? Have you made any important design
decisions?-->

The topic policy is created first if the `enforceSSL` is enabled.

### Description of how you validated changes

<!--Have you added any unit tests and/or integration tests?-->

Unit and integ tests.

### Checklist
- [x] My code adheres to the [CONTRIBUTING
GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
[DESIGN
GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*

Co-authored-by: GZ <[email protected]>
  • Loading branch information
go-to-k and GavinZZ authored Jan 31, 2025
1 parent 330a919 commit b3975c5
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 62 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": "sns:Publish",
"Condition": {
"Bool": {
"aws:SecureTransport": "false"
}
},
"Effect": "Deny",
"Principal": "*",
"Resource": {
"Ref": "TopicAddPolicy7DB03706"
},
"Sid": "AllowPublishThroughSSLOnly"
},
{
"Action": "sns:Publish",
"Effect": "Allow",
Expand All @@ -68,8 +82,26 @@
"Resource": {
"Ref": "TopicAddPolicy7DB03706"
},
"Sid": "0"
},
"Sid": "1"
}
],
"Version": "2012-10-17"
},
"Topics": [
{
"Ref": "TopicAddPolicy7DB03706"
}
]
}
},
"TopicWithSSLC879A4EA": {
"Type": "AWS::SNS::Topic"
},
"TopicWithSSLPolicy3E7ECD75": {
"Type": "AWS::SNS::TopicPolicy",
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": "sns:Publish",
"Condition": {
Expand All @@ -80,7 +112,7 @@
"Effect": "Deny",
"Principal": "*",
"Resource": {
"Ref": "TopicAddPolicy7DB03706"
"Ref": "TopicWithSSLC879A4EA"
},
"Sid": "AllowPublishThroughSSLOnly"
}
Expand All @@ -89,7 +121,7 @@
},
"Topics": [
{
"Ref": "TopicAddPolicy7DB03706"
"Ref": "TopicWithSSLC879A4EA"
}
]
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b3975c5

Please sign in to comment.