-
Notifications
You must be signed in to change notification settings - Fork 4.5k
(kms): add Key.fromKeyId(), and make Key.fromXXX().env.region reflect the region that the key was imported from #21464
Copy link
Copy link
Closed
Labels
@aws-cdk/aws-kmsRelated to AWS Key ManagementRelated to AWS Key ManagementbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp2
Description
Describe the feature
The ability to import a kms key based on the key id. And, the env for all imported keys should be the environment that they came from, not the environment of the current stack.
Use Case
When I already have the key id for a key, it is frustrating to have to go and get the ARN for that key id in order to import the key into my Construct.
const importedKey = kms.Key.fromKeyId(this, 'imported-key', 'xxx-xxx');
// should be the source region
importedKey.env.region
const anotherImportedKey = kms.Key.fromKeyId(this, 'imported-key-2', 'aws::us-east-1::.....');
// should be the source region
anotherImportedKey.env.region
Proposed Solution
I am not sure how exactly to implement fromKeyId, since you can't parse the ARN directly from the ID. But since fromKeyArn is able to get the key id without doing API lookups, I think it should be possible the other way.
Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
CDK version used
all
Environment details (OS name and version, etc.)
MacOS
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-kmsRelated to AWS Key ManagementRelated to AWS Key ManagementbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp2