CloudFront viewer protocol policy should be set to https-only¶
CloudFront connections should be encrypted during transmission over networks that can be accessed by malicious individuals. A CloudFront distribution should only use HTTPS for communication between viewers and CloudFront.
CLI Remediation Steps¶
Get the ID of the CloudFront CDN distribution you want to remediate, either via the console or CLI:
aws cloudfront list-distributions --output table --query 'DistributionList.Items[*].Id'
Save the distribution configuration to a file:
aws cloudfront get-distribution-config --id <distribution_id> > distribution-config.json
Modify the configuration file so the ViewerProtocolPolicy attribute is changed from “allow-all” to “https-only”.
Modify the configuration file to remove the following from the beginng of the file. Note the value for the “Etag” attribute before deleting because it is required for the next command.
"ETag": "ETag_Value", "DistributionConfig":
Remove the last brace
}at the very end of the configuration file.
Update the distribution configuration from the saved configuration file:
aws cloudfront update-distribution --id <distribution_id> --distribution-config file:///tmp/distribution-config.json --if-match <etag_attribute>