Borislav Hadzhiev
Thu Apr 14 2022·1 min read
Photo by Stefano Alemani
Updated - Thu Apr 14 2022
A CDK App can consist of one or more stacks.
In order to list the stacks in a CDK application we have to use the cdk list
command:
npx aws-cdk list
If we have a simple CDK application consisting of 2 stacks:
const app = new cdk.App(); new MyCdkStack(app, 'my-stack-dev', { stackName: 'my-stack-dev', }); new MyCdkStack(app, 'my-stack-prod', { stackName: 'my-stack-prod', });
The output from the command looks like:
Alternatively, we could use the alias - cdk ls
:
npx aws-cdk ls
The output from the command is the same:
We can look at all of the available flags of the cdk list
command by appending
the --help
flag.
npx aws-cdk list --help
--help
flag to the end of the command to get the list of options we can pass.The flag that I use the most is --long
, i.e.:
npx aws-cdk list --long
The --long
flag outputs information about the environments (account
and
region
) our stacks belong to:
- id: my-stack-dev name: my-stack-dev environment: account: '123456789' region: us-east-1 name: aws://123456789/us-east-1 - id: my-stack-prod name: my-stack-prod environment: account: '123456789' region: us-east-1 name: aws://123456789/us-east-1