Remediation
From Command Lineβ
-
Retrieve the current distribution configuration and capture its
ETag
:aws cloudfront get-distribution-config \
--id {{distribution-id}} \
--query 'DistributionConfig' \
> {{distribution-config}}.json
ETAG=$(aws cloudfront get-distribution-config \
--id {{distribution-id}} \
--query 'ETag' \
--output text) -
In the downloaded
{{distribution-config}}.json
, modify the cache behaviors (DefaultCacheBehavior
and an item in theCacheBehaviors.Items
array) and set theViewerProtocolPolicy
key to eitherredirect-to-https
orhttps-only
. -
Apply the updated configuration to your distribution using the saved ETag:
aws cloudfront update-distribution \
--id {{distribution-id}} \
--if-match $ETAG \
--distribution-config file://{{distribution-config}}.json