-
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
import: asks for multiple resource identifiers at once #20895
Comments
@Rabadash8820 Here are the steps to do so:
Minor note: the |
Awesome, thanks for the workaround @saltman424! |
I'm not sure if the bug that's been described here is related to CDK or CDK import - the resource that is getting created here is a Cfn resource, which means it's exactly the same resource that CloudFormation gives us. Since the API call to CloudFormation is what gives us this response, it's likely on CloudFormation's end I can report this to CloudFormation internally - tracking P67786409 |
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.
…4439) 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 #20895. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
…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*
The `cdk import` feature has existed for a year and a half. Since then, we've only had one major bug report around multiple identifiers (#20895) which was fixed half a year ago. This feature seems solid enough to remove the "Preview" label. There is only one remaining limitation around Nested Stacks, but this feature could be addressed without breaking backwards compatibility.
The `cdk import` feature has existed for a year and a half. Since then, we've only had one major bug report around multiple identifiers (#20895) which was fixed half a year ago. This feature seems solid enough to remove the "Preview" label. There is only one remaining limitation around Nested Stacks, but this feature could be addressed without breaking backwards compatibility. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Describe the bug
I am trying to use the
cdk import
command to update a CDK-managed stack with existing AWS resources. The stack is for DNSSEC resources for a domain, and I'm trying to import anAWS::Route53::KeySigningKey
. Unfortunately, the command seems to be asking for two resource identifiers at once, so I am unable to import the KeySigningKey.Expected Behavior
Running
cdk import
on a stack with anAWS::Route53::KeySigningKey
would ask for theHostedZoneId
andName
identifiers of the KeySigningKey one at a time, then importing would succeed.Current Behavior
cdk import
instead gives me this prompt (whereHostedZoneId,Name
is all in blue, like a single identifier):I've tried providing just the KeySigningKey's
HostedZoneId
, just itsName
, or both separated by a comma as the prompt suggests. In all cases, theimport
command returns the following error message (where<StackName>
is the actual name of the CDK stack into which I'mimport
ing):Adding the
--debug
flag does not provide any additional information.Reproduction Steps
cdk deploy
<value>
s:cdk import
Possible Solution
No response
Additional Information/Context
The CDK logic to ask for resource identifiers for
cdk import
is inimport.ts
file. TheresourceIdentifiers
are read from some CloudFormation GetTemplateSummary response. Using another stack with KeySigningKeys in my account as an example, I found that theResourceIdentifierSummaries
array in the GetTemplateSummary response included this object:Note the
HostedZoneId,Name
identifier. I'm not sure if this is a bug with Route53 or what, but it doesn't seem like any resource type should include a comma-delimited identifier inResourceIdentifiers
, since that field is already a string array. This may have something to do with the fact that the defaultFn::Ref
return value for a KeySigningKey is an identifier that has the format<HostedZoneId>|<Name>
. I tried passing a string with this format tocdk import
but still got the above error message.CDK CLI Version
2.29.1 (build c42e961)
Framework Version
No response
Node.js Version
v16.15.1
OS
Debian bullseye
Language
Typescript
Language Version
3.9.10
Other information
Technically running Debian in a WSL container on Windows 11 Pro
The text was updated successfully, but these errors were encountered: