[AWS][CloudFront] 既存の CloudFront をまとめて IPv6 Enabled に変更する

aws-cli でやるなら、こんな感じ

update-distribution.sh
#!/bin/bash
DIST_IDS=$(aws cloudfront list-distributions | jq -r '.DistributionList.Items[] | select(.IsIPV6Enabled == false) | .Id')
for DIST_ID in ${DIST_IDS}; do
    ETAG=$(aws cloudfront get-distribution --id ${DIST_ID} | jq -r '.ETag')
    CONFIG_JSON=$(mktemp)
    jq -s '.[0] * .[1]' <(aws cloudfront get-distribution --id "${DIST_ID}" | jq '.Distribution.DistributionConfig') <(echo '{"IsIPV6Enabled": true}') > ${CONFIG_JSON}
    aws cloudfront update-distribution --id ${DIST_ID} --distribution-config file://${CONFIG_JSON} --if-match ${ETAG}
    rm -f ${CONFIG_JSON}
done
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.