When I run cdk deploy --all
to deploy all stacks, as suggested by the aws docs, I dont get the desired behavior.
If i run cdk list
I get a list of all my stacks as such:
pipeline
pipeline/alpha-stage/externalcommunication (alpha-stage-externalcommunication)
pipeline/alpha-stage/vpc (alpha-stage-vpc)
pipeline/alpha-stage/intercommunication (alpha-stage-intercommunication)
pipeline/alpha-stage/storage (alpha-stage-storage)
pipeline/alpha-stage/service (alpha-stage-service)
pipeline/alpha-stage/observability (alpha-stage-observability)
if I run cdk deploy --all
only the pipeline stack is created and deployed
[WARNING] aws-cdk-lib.aws_ec2.LaunchTemplateProps#keyName is deprecated.
- Use `keyPair` instead - https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2-readme.html#using-an-existing-ec2-key-pair
This API will be removed in the next major release.
✨ Synthesis time: 3.02s
pipeline: deploying... [1/1]
pipeline: creating CloudFormation changeset...
✅ pipeline (no changes)
✨ Deployment time: 3.57s
Stack ARN:
arn:aws:cloudformation:eu-west-1:730335428471:stack/pipeline/2667ad20-0315-11ef-906b-0a89280ac13b
✨ Total time: 6.59s
I originally thought that maybe it wasnt seeing any differences in the other stacks, but when i deploy the stack manually it does see the diff and deploy it
cdk deploy pipeline/alpha-stage/externalcommunication --profile cs-dev
[WARNING] aws-cdk-lib.aws_ec2.LaunchTemplateProps#keyName is deprecated.
- Use `keyPair` instead - https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2-readme.html#using-an-existing-ec2-key-pair
This API will be removed in the next major release.
✨ Synthesis time: 3.39s
alpha-stage-externalcommunication: start: Building cba1532de344d46fde76a38d8b956373267f9fbc4a7fe247ce6caa08f05a9fde:730335428471-eu-west-1
alpha-stage-externalcommunication: success: Built cba1532de344d46fde76a38d8b956373267f9fbc4a7fe247ce6caa08f05a9fde:730335428471-eu-west-1
alpha-stage-externalcommunication: start: Publishing cba1532de344d46fde76a38d8b956373267f9fbc4a7fe247ce6caa08f05a9fde:730335428471-eu-west-1
alpha-stage-externalcommunication: success: Published cba1532de344d46fde76a38d8b956373267f9fbc4a7fe247ce6caa08f05a9fde:730335428471-eu-west-1
pipeline/alpha-stage/externalcommunication (alpha-stage-externalcommunication): deploying... [1/1]
alpha-stage-externalcommunication: creating CloudFormation changeset...
[█████▊····················································] (1/10)
2:35:22 PM | UPDATE_IN_PROGRESS | AWS::CloudFormation::Stack | alpha-stage-externalcommunication
2:35:25 PM | CREATE_IN_PROGRESS | AWS::Route53::HostedZone
...
So why is deploy --all
not even attempting to deploy any stack other than pipeline
?
This is because you're using CDK Pipelines, which is a module for deploying CDK applications with pipelines. This means that your applications stacks (under pipeline/
) are deployed by your pipeline, as opposed to locally / via cdk deploy
.
To deploy your stacks, simply push the code into your remote git repository and trigger the pipeline (it is triggered automatically by default).
If you want to perform an out-of-band deployment manually, you can still do so by specifying a glob pattern:
cdk deploy 'pipeline/**'
Here is the reference in the Readme:
If your application contains pipeline stacks, the cdk list command will show stack names as paths, showing where they are in the pipeline hierarchy (e.g., PipelineStack, PipelineStack/Prod, PipelineStack/Prod/MyService etc).
If you want to deploy all of them, you can use the flag --all or the wildcard * to deploy all stacks in an app. Please note that, if you have a hierarchy of stacks as described above, --all and * will only match the stacks on the top level. If you want to match all the stacks in the hierarchy, use . You can also combine these patterns. For example, if you want to deploy all stacks in the Prod stage, you can use cdk deploy PipelineStack/Prod/.