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.

  1. Go to the cloudfront distribution
  2. Select the distribution
  3. Go to behaviour
  4. select the one and click edit
  5. Now you have a option of redirecting http -> https