I'm working on setting up a CI/CD Pipeline with cdk in typescript. I have a very modular stack structure so I'm having a Stage with 3 stacks: LambdasStack, EndpointsStack and TablesStack. As the name suggest I have all my Lambdas in LambdasStack and so on.
For the pipeline I want the following flow:
- Build
- Deploy Stacks for PreProd
- Integration Test
- Destroy Stacks of PreProd
- Manual approval before Prod
- Deploy Stacks for Prod
The PreProd stacks have to be destroyed before the deployment of the Prod stacks because of the unique names of the tables within the TablesStack. And that's what I'm struggling with. My code to destroy them is:
const deletePreProdStacks= new ShellStep('Delete deployed Stacks', {
commands: [
'npm install',
'cdk destroy -f --all'
]
});
With 'cdk destroy -f --all' the stacks of the stage are not found so they can't be deleted.
How can I solve this problem? Giving the tables autogenerated names can't be the right solution? Or is there an option to overwrite the PreProdStacks to ProdStacks?
I only have access to only one AWS Account. Because I read that having Testing/PreProd stage and Prod stage on different accounts.
Maybe someone has a similar best practice reference for me?
Thanks in advance :)
Edit1: tag update Edit2: added situation about deployment of PreProd & Prod in same account