Skip to content

Instantly share code, notes, and snippets.

@ystoneman
Created March 20, 2021 15:44
Show Gist options
  • Save ystoneman/5987d5667168598940949e9b22fa36b1 to your computer and use it in GitHub Desktop.
Save ystoneman/5987d5667168598940949e9b22fa36b1 to your computer and use it in GitHub Desktop.
Find all the API Gateway APIs that have cache enabled in a given AWS region.
declare -a arr=($(aws apigateway get-rest-apis --query 'items[*].id' | tr ,[]\" ' '))
for i in "${arr[@]}"
do
declare -a stages=($(aws apigateway get-stages --rest-api-id $i --query 'item[0].stageName' | tr \" ' '))
for j in "${stages[@]}"
do
if $(aws apigateway get-stage --rest-api-id $i --stage-name $j | jq '.cacheClusterEnabled'); then
aws apigateway get-rest-api --rest-api-id $i | jq '.name'
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment