Count results with JMESPath

Count unattached EBS volumes in one call using length(); --profile/--region scope it

aws ec2 describe-volumes --filters Name=status,Values=available --query 'length(Volumes[])' --output text --profile staging --region <id>

tool
aws14 commands
tags
awsdiskcloud

More aws commands

  • aws sts get-caller-identity --query '{acct:Account,arn:Arn}' --output table

    Confirm active account, ARN and assumed role before running risky commands

  • eval $(aws sts assume-role --role-arn <id> --role-session-name ops --query 'Credentials.[`AWS_ACCESS_KEY_ID=`+AccessKeyId,`AWS_SECRET_ACCESS_KEY=`+SecretAccessKey,`AWS_SESSION_TOKEN=`+SessionToken]' --output text | sed 's/^/export /')

    Assume an IAM role and inject temp creds into the shell env in one shot

  • aws ec2 describe-instances --filters Name=tag:Env,Values=prod Name=instance-state-name,Values=running --query 'Reservations[].Instances[].{id:InstanceId,ip:PrivateIpAddress,az:Placement.AvailabilityZone}' --output table

    List running prod instances with id, private IP and AZ via JMESPath projection

  • aws s3 sync ./ s3://<name>/ --delete --exclude '*.tmp' --exclude '.git/*' --size-only

    Mirror dir to bucket; --delete removes stale keys. note: --size-only skips mtime checks

  • aws s3 presign s3://<name>/path/file.tgz --expires-in 3600

    Generate a time-limited download URL without making the object public

all 14 aws commands