-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(aws-iot-actions): SNS-Topic-Action missing master-key policies #24848
Comments
Hi iot_actions.SnsTopicAction(
sns_topic,
message_format=iot_actions.SnsActionMessageFormat.RAW,
role= iam_role
) I believe you need manually grant the read permission to the iam role before you are allowed to to that because |
Yes, that's how I currently do it. But if no role is given I would expect that the grant happens automatically inside |
@pahud Looking at As a user I would expect that |
This is something that could be better handled by our codebase - it would be great if this could automatically detect the key on the Topic. We'd need to expose this on the Topic construct first, and then handle it appropriately after that, but it should be possible! |
I'll work on it. |
### Issue # (if applicable) Fixes #18387, #31012, #24848 Pre-requisite for #16271, #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](#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*
Describe the bug
When creating an SNS topic action with a master-key the action does not work, because it does not have the permission to use the KMS-Key.
Expected Behavior
I would expect the action to work.
Current Behavior
It does not work, because of missing KMS-Key permissions.
Reproduction Steps
Possible Solution
I did not look into the source code yet, but I guess it should be possible to grant the required permissions to the sns topic action role.
The following is a workaround I currently use:
Additional Information/Context
No response
CDK CLI Version
2.70
Framework Version
No response
Node.js Version
16.15.0
OS
MacOS
Language
Python
Language Version
3.9
Other information
No response
The text was updated successfully, but these errors were encountered: