-
-
Save kwoods/adf4ba171d83c1995aa79dc8169a004a to your computer and use it in GitHub Desktop.
aws cli + jq example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget http://stedolan.github.io/jq/download/linux64/jq | |
aws ec2 describe-instances --filters "Name=tag:Name,Values=$NAME" \ | |
"Name=instance-state-name,Values=running" \ | |
| jq -r \ | |
".Reservations[] | .Instances[] | .InstanceId" \ | |
aws ec2 describe-volumes --filters \ | |
"Name=status,Values=available" \ | |
| jq -r ".Volumes[] | .VolumeId" \ | |
aws ec2 describe-instances | jq '.Reservations[].Instances[] | select(.LaunchTime > "2015-01-28") | select(.State.Code != 48) | [.LaunchTime, .State.Name, (.Tags[]|select(.Key=="Name")|.Value)]' | |
# no dotdee | |
aws ec2 describe-instances | jq --arg yest $(python -c "import datetime; t = datetime.datetime.now() - datetime.timedelta(hours=24); print t.strftime('%Y-%m-%d')") -r '.Reservations[].Instances[] | select(.LaunchTime > $yest) | select(.State.Code != 48) | (.Tags[]//[]|select(.Key=="Name")|.Value) as $name | "Host \($name) \nHostname \(.PrivateIpAddress)"' >> ~/.ssh/config | |
# list of Route 53 records | |
aws cloudformation list-stack-resources --region us-east-1 --stack-name stack_name --profile profile_name | jq '.StackResourceSummaries[] | select(.ResourceType == "AWS::Route53::RecordSet") | .PhysicalResourceId' | |
# count of CW LogGroups | |
aws logs describe-log-groups --log-group-name-prefix '/aws/lambda/recipe-box-' | jq -r ".logGroups[] | .logGroupName" | wc -l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment