Deploying Single Page Application (SPA) in Amazon Web Services (AWS) world is not that straight forward like the way SPA sounds. At Craftsmen we have been deploying SPAs in AWS cloud environment pretty frequently for our customers and thought that it’s worth sharing our practices with the world!
Suppose you have a domain called www.example.com and you want to serve a SPA (built in React, Angular, VueJS etc) web app from AWS cloud environment. Then at a first glance you will face lots of confusing stuffs like S3 bucket, Route53, Cloud Front etc which will need to be configured properly. Lets discuss about them briefly and later we will see necessary configuration steps to make them work together.
S3 Bucket: S3 is the simple cloud storage from AWS where you can store any type of file with access permissions. We will put our SPA app in a S3 bucket with public access permission, so that anyone can download files from this bucket.
CloudFront: You can think Amazon CloudFront as a CDN. In our case it will cache our static web app from a S3 bucket and will deliver it more efficiently when requested.
Route 53: You can consider Route 53 as the domain name resolver similar as NameCheap and other third parties.
We hosted our app in S3 bucket and now we want to deliver it through CloudFront for better performance and caching.
If you did not purchase your domain from AWS then following configurations needs to be done in your third party domain controller like NameCheap.
If everything goes right then the site should be available in dev.example.com.