1

I have an AWS Cdk deployer application that deployed multiple resources in AWS. The application uses a config file that acts as an input file and using that it deployed multiple was ecs task in a fargate cluster and placed them behind an application load balancer.

Is there any way to get all the components/AWS services that are being deployed when I run cdk deploy --all. I'm trying to understand without using a separate boto3 function if there is any way which was cdk provides.

2 Answers 2

6

After synth, from the cdk.out CloudAssembly:

import aws_cdk.cx_api as cx_api

cloud_assembly = cx_api.CloudAssembly("cdk.out")
resources = [stack.template["Resources"] for stack in cloud_assembly.stacks]

After deploy, with the DescribeStackResources or ListStackResources APIs:

aws cloudformation describe-stack-resources --stack-name MyStack

Both return lists of CloudFormation Resource information, but with different content. The CloudAssembly resources are from the local template generated by cdk synth. The Resources returned from boto3 or the CLI are the deployed cloud resources with resolved names.

Sign up to request clarification or add additional context in comments.

2 Comments

using the above code I am getting error: 'CloudAssembly' object is not subscribable In my deployer application I have 3 stacks.Each one I did cdk synth stackname and then ran the above CloudAssembly code
@Dcook My bad. I fixed the code and tested that it now works. If you first synth with cdk synth --all, the script will output a list with 3 maps - one map of resources for each of your app's stacks.
0

Step 1: get a list of all the CloudFormation-TEMPLATES that cdk deploy will be deploying.

Example: bash: ls cdk.out/*.template.json
Example: bash (for CodePipeline stages): ls cdk.out/asset.*/*.template.json

Step 2: Using bash/gnu:

   for f in $(ls cdk.out/*.template.json); do grep '"Type": ' "${f}"; done

If you are good python-developer, the above bash-commands can be easily rewritten in python and formatted in a much better manner.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.