Host angular web app in aws cloudfront

Amazon CloudFront is a web service that speeds up the distribution of static and dynamic web content, such as html, css, javascript, and image files.

This article will cover the steps to host an Angular web app in AWS CloudFront.

You need appropriate permissions on S3, CDN and AWS Certificate Manager.

Steps to configure CDN

  • Create an S3 bucket named webhosting
    • Create index.html with the following content
      <div "style="text-align:center""> You have successfully completed your website hosting! </div>
    • Upload index.html to the S3 bucket

  • Configure the bucket for Web Hosting
    • Select the bucket
    • Select “Properties”
    • Select “Static web hosting”
      i. For Index document enter index.html (Angular prod build generates index.html as the starting point for the website)
      ii. For Error document enter error.html (create a file called error.html to show a custom error message when users access a wrong URL)

    Step 1

    Step 2

Set Bucket policy

There are two possible options
  • Make the bucket public
  • If a custom policy is set, then make the content of the bucket publicly accessible.

Refer to this document to set bucket policy


Step 3

Create Cloudfront Distribution

  • Select services from the top menu
  • Select CloudFront
  • Select Create Distribution
  • Select Get started under “Web”


Step 4

Set “Origin Domain name” as the Endpoint of Static website hosting (Step No 2)


Step 6

Step 7

Step 8

Compress Objects Automatically – Select “Yes” for a better performance





CNAME – website name. (Optional, use this for user-friendly website name)
If alternate domain is used, an ACM (AWS Certificate Manager) certificate has to be created

Refer to this document to create ACM.



In the above image, set the “Default Root Object” to index.html