Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[AWS][CloudFront] 既存の CloudFront をまとめて IPv6 Enabled に変更する ref: https://qiita.com/wokamoto/items/7eef100532fcced8d6d0
#!/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 to join this conversation on GitHub. Already have an account? Sign in to comment