Deploy a single page app on AWS

Nicolas Girault
2 min readApr 29, 2019

--

The last 2 years, I've started from scratch tens of single page apps thanks to create-react-app. Each time, I used to replay the same routine to roll out the app:

  • create a S3 bucket
  • configure the bucket with public permission
  • setup the bucket website hosting (after importing a dummy index.html file)
  • create a CloudFront distribution and click tens of times to configure it
  • go to Route53 and create a CNAME record

Getting used to this routine, I used to perform it in less than 5 minutes. Since it was happening once in a while, I never seriously considered that scripting these actions would be worth it.

But scripting this routine is not only a question of time saving. It's also a question of quality. I realised it the last week with the 2 following events:

  • I realised that assets were not served gzipped on one of the SPAs I maintain because I made a mistake configuring the CloudFront distribution:
arf… I missed this config when I created the CloudFront distribution…
  • I adjusted the cache-control of the index.html of another app so that the browser always revalidates the file… But I didn't take the time to apply this learning to all of the other SPAs I maintain.

So yes, time had come to write some script: https://github.com/nicgirault/aws-spa.

This library is opinionated in the way it deploys a single page app: there is no possible configuration. Why? Because all my SPAs are configured the same way and I have the feeling that we all configure it similarly (or should). Please answer this survey so that I can validate this hypothesis.

Any suggestion (as a Github issue) to improve this package would also be appreciated.

I would also be interested to know how you currently deploy your SPAs: do you create AWS objects in the console? Have you written similar scripts? Do you use another package/tool? Please leave a comment to share how you deal with this.

--

--

Nicolas Girault

Web developer transforming ideas into realities. I'm reading about technologies or organizations helping producing better quality softwares in less time