It can be difficult to understand the CloudFormation resources and their dependencies when working with a complicated CloudFormation template. We’ll run through some commands to try to help understand their dependencies.

Here are the commands that I ran in the video:

curl -o "waf.json"
cat waf.json | jq '.Resources | keys[]'
cat waf.json | jq '.Resources | keys[]' | wc -l
grep DependsOn waf.json
grep DependsOn waf.json | wc -l

What the above commands did:

  1. Downloads the template
  2. Summarize the resource logical names
  3. Count the resources
  4. Summarize the DependsOn
  5. Count the explicit DependsOn usage

It’s still a little tough to visualize the dependencies though.

The lono xgraph command

You’ll need to be in a lono project. You can quickly generate one with:

lono new infra
cd infra

lono xgraph helps you visualize the dependencies with a picture.

lono import --name waf
lono xgraph waf

You end up with a dependency graph chart that looks like this.

Note, I zoomed in on the dependency graph because there are so many resources in this template. 😁

That’s it! The official documentation is at Hope that helps! 🎉 Hope that helps!

Related Post: Lono Summary Tutorial Introduction - Summarize CloudFormation Template