CloudFormation has support for importing existing resources into a stack. You can use the ResourcesToImport parameter to createChangeSet to do it.
Could AWS CDK support importing existing resources? The current implementation that calls createChangeSet does not seem to pass the ResourcesToImport parameter in any situation.
I tried to search for existing issues about this. They are hard to find because many issues talk about importing exported values or importing a reference to a resource in another stack. But here I mean importing orphaned cloud resources.
Typical use cases are:
These use cases are important when the orphaned resource contains data, e.g. a DynamoDB table or a S3 bucket that cannot be deleted.
I am not sure about all the details that are related using to ResourcesToImport. It probably requires a lot of testing with different AWS resource types to make it work.
In a perfect world AWS CDK would automatically import named resources when it notices that the resource already exists outside the stack. It would ask the user for confirmation if there are any issues, like having to tune the resource policy/permissions/properties to make the import work.
This is a :rocket: Feature Request
There are ways to use existing resources in CDK apps. See the Resources topic in the Developer Guide. Does that help?
@Jerry-AWS No. Like I said in the issue description, I'm not talking about referring to external resources. I'm talking about importing orphaned resources back into a CloudFormation stack so that CloudFormation actually takes ownership of the resource. CloudFormation supports this, so I think AWS CDK could support it too.
We are tracking this in the RFC repo, see https://github.com/aws/aws-cdk-rfcs/issues/52. Closing this in favor of the RFC issues.
Is there any workaround to reattach an orphaned s3 to cdk stack ?
Because fromBucketArn doesn't allow to modify an existing s3 bucket, i am facing a deadlock ...
Most helpful comment
@Jerry-AWS No. Like I said in the issue description, I'm not talking about referring to external resources. I'm talking about importing orphaned resources back into a CloudFormation stack so that CloudFormation actually takes ownership of the resource. CloudFormation supports this, so I think AWS CDK could support it too.