• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

AWS CLI Using Query

November 11, 2020

Instead of using AWS and JQ to get the snapshot names, you can do it with a single command using –query.

Here are the previous commands.

/usr/bin/aws lightsail get-instance-snapshots --region us-east-1 --profile default > $snaps
cat $snaps | jq -r '.instanceSnapshots[] | .name' > $names

/usr/bin/aws lightsail get-instance-snapshots --region us-east-1 --profile default > $snaps cat $snaps | jq -r '.instanceSnapshots[] | .name' > $names

Using query.

aws lightsail get-instance-snapshots \
--query 'instanceSnapshots[*].[name]' \
--region us-east-1 \
--profile default \
--output text > $names

aws lightsail get-instance-snapshots \ --query 'instanceSnapshots[*].[name]' \ --region us-east-1 \ --profile default \ --output text > $names

Filed Under: Cloud Tagged With: aws cli, lightsail, query, snapshots

Search This Website

Subscribe Via Email

  • Home
  • About
  • Archives

Copyright © 2023