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" https://s3.amazonaws.com/solutions-reference/aws-waf-security-automations/latest/aws-waf-security-automations.template
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:
- Downloads the template
- Summarize the resource logical names
- Count the resources
- Summarize the DependsOn
- 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 https://s3.amazonaws.com/solutions-reference/aws-waf-security-automations/latest/aws-waf-security-automations.template --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 lono.cloud/reference/lono-xgraph. Hope that helps! 🎉 Hope that helps!
Related Post: Lono Summary Tutorial Introduction - Summarize CloudFormation Template