Skip to content

Instantly share code, notes, and snippets.

@palashkulsh
Last active February 17, 2022 06:11
Show Gist options
  • Save palashkulsh/1814bde610b2455de1ccf4b24af63aee to your computer and use it in GitHub Desktop.
Save palashkulsh/1814bde610b2455de1ccf4b24af63aee to your computer and use it in GitHub Desktop.
aws cli describe instance scripts
aws ec2 describe-instances --filters "Name=tag:Service,Values=marketplace-esclus" | jq '.Reservations[].Instances[] | "\(.PrivateIpAddress) , \(.EbsOptimized) , \(.SubnetId) , \(.Placement.AvailabilityZone) , \(.Tags[]| select(.Key == "Hostname") | .Value) , \(.InstanceType)"'
@palashkulsh
Copy link
Author

palashkulsh commented Jan 14, 2020

###find instances with given tags

aws ec2 describe-instances --filters "Name=tag:Techteam,Values=mall-cart" "Name=tag:Role,Values=redis" --region ap-south-1 | jq '.Reservations[].Instances[] | "\(.PrivateIpAddress),\(.Tags[]| select(.Key == "Hostname") | .Value) "'

@palashkulsh
Copy link
Author

palashkulsh commented Feb 27, 2020

cat ip.txt | sudo xargs -I {} aws ec2 describe-instances --filter Name=private-ip-address,Values={} --region ap-south-1 | jq --arg tag1 "Service" --arg tag2 "Team" '.Reservations[].Instances[] | "\(.PrivateIpAddress) , \(.Tags[]| select(.Key==$tag1) | .Value) "'

@palashkulsh
Copy link
Author

aws ec2 describe-instances --filters "Name=tag:Name,Values=xxx" "Name=tag:env,Values=dev"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment