I have a CDK project where initially it was deployed via CLI. I am now wrapping it in a pipelines construct.
Old:
Project
|
Stacks
|
Resources
New:
Project
|
Pipeline
|
Stage
|
Stacks
|
Resources
The issue I’m running into is that there are resources I would rather not be deleted in the application, however adding the stage causes the logical ID’s to change to Stage-Stack-Resource
from Stack-Resource
. I found this article that claims you can provide an id of ‘Default’ to a resource, and cause it to go unused in the process of making the logical ID. however for some reason when I pass an Id of Default to the stage it simply uses that "Default" literal value instead of omitting it.
End goal is that I can keep my existing cloudformation resources, but have them deployed via this pipeline.
2
Answers
I ended up doing a full redeploy of the application. Luckily this was a development environment where trashing our data stores isn't a huge loss. But would be much more of a concern in a production environment.
You can override the logical id manually like this:
S3 example:
However, if you did not specify a logical id initially and do it now, CloudFormation will delete the original resource and create a new one with the new custom logical id because CloudFormation identifies resources by their logical ID.
Stage
is something you define and it is not related to CloudFormation. You are probably using it in your Stack name or in your Resource names and that’s why it gets included in the logical id.Based on your project description, the only option to not have any resources deleted is: make one of the pipeline stages use the exact same stack name and resource names (without
stage
) as the CLI deployed version.