AWS Cloudfront distribution ID by tag

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-09 11:12:46

问题


is that possible to get aws cloudfront dist id by tag via awscli or aws sdk for powershell. I could only get only ID by ARN number of resource

aws cloudfront list-tags-for-resource --resource XXX
{
   "Tags": {
       "Items": [
           {
               "Value": "TEST_APP",
               "Key": "CLIENT_APP"
           }
       ]
   }
}

UPDATE

Solved via

cloudfrontdistids=$(aws cloudfront list-distributions | jq -r ".DistributionList.Items[].ARN")
for dist in $cloudfrontdistids
do
        if [ $(aws cloudfront list-tags-for-resource --resource $dist | jq -r ".Tags.Items[].Value") == $VALUE ]
        then
                CLOUDFRONT_DISTRIBUTION_ID=${dist:(-14)}
        fi
done

来源:https://stackoverflow.com/questions/58009093/aws-cloudfront-distribution-id-by-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!