Skip to content
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

feat(kms): support fromLookup in KMS key to get key by alias name #15652

Merged
merged 7 commits into from
Sep 3, 2021

Conversation

jumic
Copy link
Contributor

@jumic jumic commented Jul 19, 2021

Add method fromLookup in KMS key which provides the option to get a KMS key including its key id by an alias name.
In some cases, aliases can't be used because access to the underlying key id is necessary. In this case, the fromLookup method can be used.

The following packages were changed:

  • @aws-cdk/aws-kms: introduce new fromLookup method
  • @aws-cdk/cx-api: new KeyContextResponse
  • @aws-cdk/cloud-assembly-schema: new ContextProvider KEY_PROVIDER and KeyContextQuery
  • aws-cdk: implementation of key ContextProvider

Closes #8822


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

@gitpod-io
Copy link

gitpod-io bot commented Jul 19, 2021

@peterwoodworth peterwoodworth added the @aws-cdk/aws-kms Related to AWS Key Management label Jul 20, 2021
@jumic
Copy link
Contributor Author

jumic commented Jul 24, 2021

Note: Version of cloud-assembly-schema was increased. --> Check/update version again when this PR will be merged.

@jumic jumic marked this pull request as ready for review July 24, 2021 21:03
@njlynch njlynch added effort/medium Medium work item – several days of effort p2 labels Jul 30, 2021
@njlynch
Copy link
Contributor

njlynch commented Jul 30, 2021

Thanks so much for submitting this pull request. I am marking this pull request as p2, which means that we are unable to work on it immediately, but it's definitely still on our radar.

We use +1s to help prioritize our work, and are happy to revaluate this pull request based on community feedback. You can reach out to the cdk.dev community on Slack to solicit support for reprioritization.

@njlynch njlynch added p1 and removed p2 labels Aug 24, 2021
Copy link
Contributor

@njlynch njlynch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really great.

A few updates to the README, and one change to the ARN formatting; other than that, looks ready to go. Thanks for the contribution!

Comment on lines 126 to 128
Note that a call to `.addToPolicy(statement)` on `myKeyLookup` will not have
an affect on the key's policy because it is not owned by your stack. The call
will be a no-op.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this copy/pasted from somewhere else? There's no addToPolicy on the Key interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. This was copied from method Key.fromKeyArn which is described in the same readme file.
Method addToPolicy is mentioned there. addToResourcePolicy is the correct name of this method. It is defined in class KeyBase.

I did the correction in the original text and in the new description for fromLookup.

@mergify mergify bot dismissed njlynch’s stale review August 27, 2021 22:39

Pull request has been modified.

@jumic
Copy link
Contributor Author

jumic commented Aug 27, 2021

Thanks for your feedback. 👍 I've implemented the suggested changes.

The cloud-assembly-schema version is still up-to-date. Current version is 13, will be increased to 14 by this PR.

@argenstijn
Copy link

+1

Copy link
Contributor

@njlynch njlynch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution!

@mergify
Copy link
Contributor

mergify bot commented Sep 3, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 8d5c7ed
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 34a57ed into aws:master Sep 3, 2021
@mergify
Copy link
Contributor

mergify bot commented Sep 3, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Sep 6, 2021
…s#15652)

Add method `fromLookup` in KMS key which provides the option to get a KMS key including its key id by an alias name.
In some cases, aliases can't be used because access to the underlying key id is necessary. In this case, the `fromLookup` method can be used.

The following packages were changed:
- @aws-cdk/aws-kms: introduce new `fromLookup` method
- @aws-cdk/cx-api: new KeyContextResponse
- @aws-cdk/cloud-assembly-schema: new ContextProvider KEY_PROVIDER and KeyContextQuery
- aws-cdk: implementation of key ContextProvider

Closes aws#8822 

-----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
david-doyle-as24 pushed a commit to david-doyle-as24/aws-cdk that referenced this pull request Sep 7, 2021
…s#15652)

Add method `fromLookup` in KMS key which provides the option to get a KMS key including its key id by an alias name.
In some cases, aliases can't be used because access to the underlying key id is necessary. In this case, the `fromLookup` method can be used.

The following packages were changed:
- @aws-cdk/aws-kms: introduce new `fromLookup` method
- @aws-cdk/cx-api: new KeyContextResponse
- @aws-cdk/cloud-assembly-schema: new ContextProvider KEY_PROVIDER and KeyContextQuery
- aws-cdk: implementation of key ContextProvider

Closes aws#8822 

-----

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

Is it possible to support Alias name and Alias ARN? so we can lookup Alias in different account

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-kms Related to AWS Key Management effort/medium Medium work item – several days of effort p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[KMS] Add Alias.fromLookup()
6 participants