forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sns): for SSE topics, add KMS permissions in grantPublish (aws#32794
) ### Issue # (if applicable) Fixes aws#18387, aws#31012, aws#24848 Pre-requisite for aws#16271, aws#29511 ### Reason for this change For SNS topics with SSE enabled, the grants added by `grantPublish` are insufficient, since they don't include any KMS actions. The SNS docs discuss what's required to publish to an encrypted topic [here](https://docs.aws.amazon.com/sns/latest/dg/sns-key-management.html#sns-what-permissions-for-sse) (`sns:Publish`, `kms:Decrypt`, `kms:GenerateKeyData*`). ### Description of changes I used the SQS queue implementation as a reference, since it's configured similarly, etc. * Have `Topic#grantPublish` grant `kms:Decrypt` + `kms:GenerateKeyData*` * This is least-privilege, but slightly inconsistent with SQS queues, which [need these same actions](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-key-management.html) and use `grantEncryptDecrypt` (but I have no preference -- just let me know what's best) * Exposes `masterKey` as a property of `ITopic` so callers can access it after creation * Enables [this](aws#16271 (comment)), for example, and in general makes it consistent with SQS queues ### Describe any new or updated permissions being added (Discussed above) ### Description of how you validated changes * Unit/integration tests * `yarn integ test/aws-sns/test/integ.sns.js --update-on-failed` ### 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*
- Loading branch information
1 parent
b3edd0d
commit f1c0926
Showing
15 changed files
with
36,317 additions
and
50 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...s-cdk-testing/framework-integ/test/aws-sns/test/fixtures/publish-encrypted-topic/index.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import os | ||
import boto3 | ||
|
||
client = boto3.client('sns') | ||
|
||
def lambda_handler(event, context): | ||
client.publish(TopicArn=os.environ['TOPIC_ARN'], Message='hello world') | ||
return 'published successfully' |
19 changes: 16 additions & 3 deletions
19
...-cdk-testing/framework-integ/test/aws-sns/test/integ.sns.js.snapshot/SNSInteg.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...est/aws-sns/test/integ.sns.js.snapshot/SNSTestDefaultTestDeployAssert607DA316.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.