How to create cloudfront distribution for a static website hosted in AWS S3 ?
June 23, 2020 / Eternal Team
Ever wondered how you can host a static website using Amazon S3? and serve it via CloudFront CDN. Follow along with us to know more about it.
- Create a CloudFront web distribution. In addition to the distribution settings that you need for your use case, enter the following.
- For Origin Domain Name, select the bucket that you created.
- For Restrict Bucket Access, select Yes.
- For Origin Access Identity, select Create a New Identity.
- For Comment, you can choose to keep the default value. Or, you can enter a custom label for the OAI.
- For Grant Read Permissions on Bucket, select Yes, Update Bucket Policy.
- If you don’t want to use SSL (HTTPS) for your website, proceed to the next step. To use SSL for your website, for SSL Certificate, you can select the Default CloudFront Certificate or a Custom SSL Certificate. Or, you can choose Request or Import a Certificate with ACM to request a new certificate. Important: If you entered Alternate Domain Names (CNAMEs) for your distribution, the CNAMEs must match the SSL certificate that you select. For more information, see Using Alternate Domain Names and HTTPS.
- Note: If you don’t have a domain to point the cloudfront please skip the Custom SSL Certificate and select Default CloudFront Certificate.
- Choose to Create Distribution.
- The distribution will go in In Progress mode wait until the distribution is deployed state.
- Now copy the domain looking like example.cloudfront.net and point to you domain and will start working ( optional ) you can also run the website on example.cloudfront.net