Create a CloudFront Distribution
This section describes how to create an Amazon CloudFront distribution that securely delivers content from your S3 bucket using HTTPS. CloudFront will serve as the global CDN and enforce secure access to the bucket.
-
Sign in to the AWS Management Console and open the CloudFront console.
-
Choose Create distribution.
-
Select the appropriate pricing class based on your expected traffic and geographic coverage.
-
Enter a distribution name and set the type to Single website or app.
-
Under Specify origin, configure the following:
Setting Value Origin type Amazon S3 Origin Select your S3 bucket Allow private S3 bucket access to CloudFront Enabled Origin settings Use recommended settings -
Under Cache settings, choose Customize cache settings, then configure:
Setting Value Viewer protocol policy Redirect HTTP to HTTPS Allowed HTTP methods GET, HEAD Cache policy CachingOptimizedOrigin request policy None Response headers policy SimpleCORSorSecurityHeadersPolicyThese settings enforce HTTPS, optimize caching performance, and apply essential security headers.
-
(Optional) Enable AWS WAF if you want to apply firewall protections.
-
Review the settings and choose Create distribution.
The distribution will enter In progress status and may take 10–15 minutes to deploy globally.
Add alternate domains
-
After the distribution is created and deployed, open it in the CloudFront console.
-
On the General tab, choose Add a domain.
-
Enter the domain names you want to serve (for example:
example.com,www.example.com). -
Select your ACM SSL certificate, choose a security policy, choose allowed HTTP versions, and select Save.
Configure error pages
-
In your distribution, open the Error pages tab.
-
Choose Create custom error response, then configure:
Field Value HTTP error code 403 Error caching minimum TTL 10 (default) Customize error response Yes Response page path Path to your error.htmlHTTP response code 200 This prevents users from seeing XML “AccessDenied” messages.
-
(Optional) Add similar rules for other HTTP status codes as needed.
Verification checklist
Before moving on, confirm the following:
| Setting | Expected |
|---|---|
| Origin access | OAC |
| Viewer protocol policy | Redirect HTTP to HTTPS |
| SSL certificate | Correct ACM certificate selected |
| Alternate domain names | Added and saved |
| Custom error page | Configured (recommended) |