Shortly after the last video CloudFormation Templates and jq Tips, I wanted to know what the required parameters in a CloudFormation template were. This is also an easy task with
jq. I’ll show you how to use jq to quickly summarize the required and optional parameters in a CloudFormation template in this post. It’s a one-liner 😁
First, we’ll download a sample template:
wget "https://s3.amazonaws.com/cloudformation-templates-us-east-1/EC2InstanceWithSecurityGroupSample.template" mv EC2InstanceWithSecurityGroupSample.template ec2.json
To list the required parameters:
$ cat ec2.json | jq -r '.Parameters | to_entries | . | select(.value.Default == null) | .key' KeyName
To list the optional parameters:
$ cat ec2.json | jq -r '.Parameters | to_entries | . | select(.value.Default != null) | .key' InstanceType SSHLocation
Hope you found this helpful. 🎉 This is also even shorter and sweeter with lono inspect summary.
Thanks for reading this far. If you found this article useful, I'd really appreciate it if you share this article so others can find it too! Thanks 😁 Also follow me on Twitter.
Got questions? Check out BoltOps.