Skip to content

Instantly share code, notes, and snippets.

@palashkulsh
Created November 24, 2017 10:20
Show Gist options
  • Save palashkulsh/b31ef87f44d382f56a5cf8263e93d5a6 to your computer and use it in GitHub Desktop.
Save palashkulsh/b31ef87f44d382f56a5cf8263e93d5a6 to your computer and use it in GitHub Desktop.
get aws tags of private ip address using aws cli and jq
#ip.csv file should have single column of private ip
cat ip.csv | xargs -I {} aws ec2 describe-instances --filter Name=private-ip-address,Values={} | jq --arg tag1 "Service" --arg tag2 "Team" '.Reservations[].Instances[] | "\(.PrivateIpAddress) , \(.Tags[]| select(.Key==$tag1) | .Value) , \(.Tags[]| select(.Key==$tag2) | .Value)"' > ip_service_team.csv
@palashkulsh
Copy link
Author

sudo aws autoscaling describe-auto-scaling-groups --region=ap-south-1 --query 'AutoScalingGroups[] | [?contains(Tags[?Key==`Techteam`].Value, `mall-payout`)]' | jq '.[] | "\(.AutoScalingGroupName),\(.MixedInstancesPolicy.InstancesDistribution.OnDemandBaseCapacity),\(.MixedInstancesPolicy.InstancesDistribution.OnDemandPercentageAboveBaseCapacity),\(.MixedInstancesPolicy.InstancesDistribution.SpotInstancePools),\(.MixedInstancesPolicy.InstancesDistribution.SpotAllocationStrategy),\(.MaxSize),\(.MinSize),\(.DesiredCapacity),\(.TerminationPolicies[]),\( .MixedInstancesPolicy.LaunchTemplate.Overrides| try map(.InstanceType) catch ["not found"] | join(";") )"'

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