How to force cloudfront to use https (redirect http -> https)
If you're using CloudFormation:
Resources:
Distribution:
Type: AWS::CloudFront::Distribution
Properties:
...
DistributionConfig:
DefaultCacheBehavior:
ViewerProtocolPolicy: redirect-to-https
...
Previous answer said to use https-only but that will return a 403 (Forbidden) if the viewer sends an HTTP request.
https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CacheBehavior.html
To force http -> https.
- Go to the cloudfront distribution
- Select the distribution
- Go to behaviour
- select the one and click edit
- Now you have a option of redirecting http -> https