Skip to content

Instantly share code, notes, and snippets.

@Rajaneeshs
Last active February 2, 2024 05:56
Show Gist options
  • Save Rajaneeshs/d0a29e996be3830b8ea11cfa9ecab1f0 to your computer and use it in GitHub Desktop.
Save Rajaneeshs/d0a29e996be3830b8ea11cfa9ecab1f0 to your computer and use it in GitHub Desktop.
#Query LB using tag by jq
aws resourcegroupstaggingapi get-resources --resource-type-filters "elasticloadbalancing:loadbalancer" --tag-filters "Key=elbv2.k8s.aws/cluster, Values=test" --tags-per-page 100 --region eu-west-1 --query "ResourceTagMappingList[].ResourceARN"
#Query LB using tag by native filter
aws resourcegroupstaggingapi get-resources --tag-filters "Key=elbv2.k8s.aws/cluster, Values=test" --tags-per-page 100 --region eu-west-1|jq '.ResourceTagMappingList| .[].ResourceARN|select (test("targetgrou."))'
#list ubuntu latest image by filter in all available regiosn
for region in `aws ec2 describe-regions --output text | cut -f4` [11:21:11]
do
echo -e "\nListing AMI in region:'$region'..."
aws ec2 describe-images --owners 679593333241 --filters "Name=name,Values=ubuntu-eks/k8s_1.27/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-202402*" --query 'Images | sort_by(@, &CreationDate) | [-1].ImageId' --output text --region $region
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment