This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| virtualization:cloud:aws:jq [2021/02/25 07:07] – jotasandoku | virtualization:cloud:aws:jq [2023/11/02 14:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | + | | |
| - | JQ stands for 'json query' | + | * Medium introduction [[https:// |
| - | | + | * Excellent/ |
| - | * Arrays (lists) | + | |
| - | * strings | + | |
| jq . # the dots means ' | jq . # the dots means ' | ||
| + | For __Docker__: | ||
| + | networks: | ||
| + | aws ec2 describe-subnets | jq .[] | jq .[].Ipv6CidrBlockAssociationSet | jq .[].Ipv6CidrBlockState | ||
| aws ec2 describe-regions | aws ec2 describe-regions | ||
| aws ec2 describe-vpcs | jq -r " | aws ec2 describe-vpcs | jq -r " | ||
| aws ec2 describe-vpcs | jq -r '.Vpcs | length' | aws ec2 describe-vpcs | jq -r '.Vpcs | length' | ||
| aws ec2 describe-vpcs --region eu-west-1 | jq -r '.Vpcs | length' | aws ec2 describe-vpcs --region eu-west-1 | jq -r '.Vpcs | length' | ||
| + | cat response.json | jq .data | jq -r ' | ||
| + | cat response.json| jq .data | jq -r ' | ||
| + | cat response.json| jq '.data | .[] | .attributes' | ||
| + | cat response.json| jq '.data | .[] | .attributes.subobject.dns_scoping' | ||
| + | |||
| + | PRETTY TABLE FORMAT:\\ | ||
| + | |||
| + | aws ec2 describe-instances \ | ||
| + | --query ' | ||
| + | --filters " | ||
| + | --output table | ||
| + | |||
| + | {{: | ||
| + | |||
| + | |||
| + | |||
| + | Lists the public IPs (querying the OCI DNS): | ||
| + | oci dns record zone get --zone-name-or-id oci.mycompany1.co.uk | jq -r ' | ||
| + | oci dns record zone get --zone-name-or-id lhr.oci.mycompany1.co.uk | jq -r ' | ||
| + | oci compute instance get --instance-id ocid1.instance.oc1.uk-london-1.anwgiljrgghpcsic6lrm3u5zqh7vwqqvsv44ewyjybis3lzhhb7bqmizelrq | jq -r '.data | .[" | ||
| + | oci network vcn list --region=eu-frankfurt-1 --compartment-id=$cs | jq -r ' | ||
| + | |||
| | | ||
| - | For containers/ | + | Folsom: |
| - | | + | |
| - | | + | |
| + | * response is 1st level, and has many ' | ||
| + | * which are attribute blocks | ||
| + | | ||
| + | |||
| | | ||
| - | oci compute instance list --compartment-id=$cb | jq -r ' | + | oci compute instance list --compartment-id=$cb | jq -r ' |
| oci compute instance list --compartment-id=$cb | jq -r ' | oci compute instance list --compartment-id=$cb | jq -r ' | ||
| | | ||
| This filters with id but extracts the pair, not the key [[https:// | This filters with id but extracts the pair, not the key [[https:// | ||
| + | |||
| + | \\ | ||
| + | oci network nsg list --region us-phoenix-1 --compartment-id ocid1.compartment.oc1..aaaaaaaax5zpuw6ggeudpiqueidy5xlqentk2ngs7p6445an34mgwlrpbccq | jq -r ' | ||
| + | |||
| + | \\ | ||
| + | Formatted output with my own labels [[https:// | ||
| + | .[]|{ | ||
| + | Name, Gateway: .IPAM.Config[]|.Gateway, | ||
| + | Endpoints: [ | ||
| + | .Containers|to_entries[]|{ | ||
| + | Name: .value.Name, | ||
| + | ] | ||
| + | } | ||
| + | | ||
| + | docker network inspect bg0 | jq -f myfilterabove | ||
| + | |||
| + | |||
| + | * '' | ||
| + | |||
| + | |||