-
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
fix(cli): cannot cdk import
resources with multiple identifiers
#24439
Conversation
Some resources that can be imported by CloudFormation allow multiple identifiers. For example, `AWS::DynamoDB::GlobalTable` allows `TableName`, `TableArn`, and `TableStreamArn`. The CLI used to interpret multiple identifiers as "all must be present", but the contract is actually "exactly one must be present": * CloudFormation would fail the import if you supply all the fields; * but CDK would skip the import if you left one out. The effect is that it is impossible to import resources that allow more than one identifier. Fix this by being satisfied as soon as we have one identifier from the set, instead of expecting all of them to be filled. Fixes #20895.
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.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
Ah the reality is slightly more complicated.
|
cdk import
resources that allow multiple identifierscdk import
resources with multiple identifiers
✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.
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). |
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). |
…s#24439) When CloudFormation tells us about identifiers for resources it can import, it returns a `string[]`. Our CLI used to interpret this as a set of identifiers that all must be present. Instead, the contract is actually: each `string` is a comma-separated list of identifiers that must be present together, but from all `strings` exactly one key combination should be supplied (and not multiple). So: * `['BucketName']` -> Supply BucketName (easy) * `['TableName', 'TableArn']` -> supply exactly one of TableName or TableArn (but not both) * `['HostedZoneId,Name']` -> supply BOTH HostedZoneId and Name. Because of our misinterpretations, both the cases of resources with multiple POSSIBLE identifiers as well as multiple REQUIRED identifiers would fail to import. Make the code correctly model the expect types: identifiers are a `string[][]`, where the outer array indicates `OR` and the inner array indicates `AND`. * For any of the combinations of properties we can lift from the template, prompt the user to confirm (typically 0 or 1, might be more). If the user rejected any of them, we don't do the resource at all. * If we couldn't lift any full key from the template, ask the user for the properties of each compound key, lifting parts of it from the template if possible. Fixes aws#20895. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
When CloudFormation tells us about identifiers for resources it can import, it returns a
string[]
.Our CLI used to interpret this as a set of identifiers that all must be present. Instead, the contract is actually: each
string
is a comma-separated list of identifiers that must be present together, but from allstrings
exactly one key combination should be supplied (and not multiple).So:
['BucketName']
-> Supply BucketName (easy)['TableName', 'TableArn']
-> supply exactly one of TableName or TableArn (but not both)['HostedZoneId,Name']
-> supply BOTH HostedZoneId and Name.Because of our misinterpretations, both the cases of resources with multiple POSSIBLE identifiers as well as multiple REQUIRED identifiers would fail to import.
Make the code correctly model the expect types: identifiers are a
string[][]
, where the outer array indicatesOR
and the inner array indicatesAND
.Fixes #20895.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license