I can only think of one way, since aws cloudfront
doesn't directly support get distributions by tag.
we can use resourcegroupstaggingapi
cli , to get ResourceARNs of all cloudfront and using jq
and sed
extract DistributionIds
Ex: Tag ApplicationID=APP1111
aws resourcegroupstaggingapi get-resources --tag-filters Key=ApplicationID,Values=APP1111 --resource-type-filters 'cloudfront' --tags-per-page 100 | jq -r ".ResourceTagMappingList[].ResourceARN" | sed 's:.*/::'
we can further use xargs and execute get-distribution for each Id.
aws resourcegroupstaggingapi get-resources --tag-filters Key=ApplicationID,Values=APP1111 --resource-type-filters 'cloudfront' --tags-per-page 100 | jq -r ".ResourceTagMappingList[].ResourceARN" | sed 's:.*/::' | xargs -I {} aws cloudfront get-distribution --id {}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…