Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Created May 1, 2018 08:39
Show Gist options
  • Save wokamoto/a2eaa7d0eb541240b7eefc34604db045 to your computer and use it in GitHub Desktop.
Save wokamoto/a2eaa7d0eb541240b7eefc34604db045 to your computer and use it in GitHub Desktop.
[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