Skip to content

Instantly share code, notes, and snippets.

@aspen-roller
Last active March 11, 2021 23:25
Show Gist options
  • Save aspen-roller/5b25bd203484ec29d2afd2d934a88e41 to your computer and use it in GitHub Desktop.
Save aspen-roller/5b25bd203484ec29d2afd2d934a88e41 to your computer and use it in GitHub Desktop.
query cloud resources / images #azure #query #aws
# https://docs.microsoft.com/en-us/cli/azure/query-azure-cli?view=azure-cli-latest
# https://docs.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage
# install query editor
# pipe query results as json to jpterm to use this
pip install jmespath-terminal
# live query editor example
az vm list --output json | jpterm
# list all vnets
az network vnet list --query '[].{name:name, prefixes:addressSpace.addressPrefixes, resourceGroup:resourceGroup}'
# list all image versions for Canonical
az vm image list --location westus2 --publisher Canonical --all -o table
az vm image list --location westus2 --publisher Canonical --sku 18.04-LTS --all --query '[].{version:version}' -o table
# show details of ubuntu image
az vm image show --location westus2 --urn Canonical:UbuntuServer:18.04-LTS:latest
# show the power state of vms in a resource group
az vm list -d --query "[?resourceGroup=='QA2']" -o table
# find aws amis
# Owner = Canonical, Ubuntu-20.04
aws ec2 describe-images --owners 099720109477 --filters "Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment