We can combine get-usage-plan-keys
and get-usage
with xargs
to extract for every api key at once.
aws apigateway get-usage-plan-keys --usage-plan-id xx44ww | jq -r ".items[].id" | xargs -I {} aws apigateway get-usage --usage-plan-id xg4j0w --key-id {} --start-date 2021-01-01 --end-date 2021-01-24 --no-paginate > output.json
Breaking it down for better readability:
Getting usage plan keys:
aws apigateway get-usage-plan-keys --usage-plan-id xx44ww
Extracting plan keys
| jq -r ".items[].id"
loop for every api key id with xargs
aws apigateway get-usage --usage-plan-id xg4j0w --key-id {} --start-date 2021-01-01 --end-date 2021-01-24 --no-paginate
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…