Skip to content

A list of examples using aws cli in conjunction with jq

Notifications You must be signed in to change notification settings

jvidalgz/aws-cli-jq-cheat-sheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Show VpcId and CidrBlock from Vpcs containing network mask of 16 bits

 aws ec2 describe-vpcs | jq '.Vpcs[] | select(.CidrBlock | contains ("/16")) | { VpcId:.VpcId,CidrBlock:.CidrBlock }'                                            

Output

{                                                                                                                                                                       
  "VpcId": "vpc-example-aa",                                                                                                                                                 
  "CidrBlock": "172.31.0.0/16"                                                                                                                                                 
}                                                                                                                                                                                            
{                                                                                                                                                     
  "VpcId": "vpc-example-bb",                                                                                                                                               
  "CidrBlock": "192.168.0.0/16"                                                                                                                                                                         
}  

Show subnets with Tag Name equal to "DMZ"

aws ec2 describe-subnets | jq '.Subnets[] | select(any(.Tags[]?; .Key == "Name" and .Value == "DMZ"))'

Output

{
  "Ipv6CidrBlockAssociationSet": [],
  "MapPublicIpOnLaunch": false,
  "AssignIpv6AddressOnCreation": false,
  "AvailabilityZone": "us-east-1a",
  "AvailableIpAddressCount": 251,
  "Tags": [
    {
      "Value": "DMZ",
      "Key": "Name"
    }
  ],
  "State": "available",
  "SubnetId": "subnet-example-aa",
  "CidrBlock": "192.168.1.0/24",
  "VpcId": "vpc-example-bb",
  "DefaultForAz": false
}                  

About

A list of examples using aws cli in conjunction with jq

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published