-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(kms): implement .grant methods for Alias.fromAliasName (under feature flag) #34237
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
Conversation
76f451a
to
5acef15
Compare
Sorry, im fairly new to the GH review flow, I missed publishing these comments earlier |
Thanks @matboros, appreciate your review. I added them along with a few more notes about the flag in README and the method docs. I rebased based on latest main branch that broke the build here. |
I requested a security review for this pr. |
…ResourceAliases condition closes: aws#22697
…issionsToPrincipal flag Co-authored-by: Matyas Boros <[email protected]>
…/README.md Co-authored-by: Matyas Boros <[email protected]>
Co-authored-by: Matyas Boros <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appsec approved
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
packages/@aws-cdk-testing/framework-integ/test/aws-kms/test/integ.alias-from-alias-name.ts
Outdated
Show resolved
Hide resolved
…est/aws-kms/test/integ.alias-from-alias-name.ts Co-authored-by: Matyas Boros <[email protected]>
Thanks for the quick iteration, unfortunately you will have to run the integ tests locally again, and update the generated template to match the new test code :( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
This pull request has been removed from the queue for the following reason: The pull request can't be updated. You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. |
➡️ PR build request submitted to A maintainer must now check the pipeline and add the |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Comments on closed issues and PRs are hard for our team to see. |
This uses the kms:ResourceAliases condition to add statements allowing the methods to the principal of the grant.
Issue
Closes #22697
Reason for this change
When using KMS keys cross stacks, it's sometimes difficult to pass KMS key IDs as they are only generated after deployment, however KMS key aliases could be passed instead and most services accept them. Some constructs that accept a KMS Alias, use .grant methods to add permissions to the role that interacts with the KMS key. Before this PR, the .grant methods of Alias.fromAliasName were not implemented.
Description of changes
This PR implements .grant methods for aliases imported via kms.Alias.fromAliasName so when passed to another a L2 construct that uses .grant methods, the required permissions are added to the role. The added statements will contain a kms:ResourceAliases condition that only allows access to the particular KMS key alias name.
Couple of examples where this is useful:
Describe any new or updated permissions being added
.grant methods of Alias.fromAliasName now results in new statements with kms:ResourceAliases condition for that alias.
Description of how you validated changes
Added unit tests and integration tests:
packages/@aws-cdk-testing/framework-integ/test/aws-kms/test/integ.alias-from-alias-name.ts
packages/aws-cdk-lib/aws-kms/test/alias.test.ts
Deployed my personal project which used Pipelines constructs with imported bucket and kms key from alias and now my pipeline role has correct permissions.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license