Deploy a Flutter web app and API to AWS CloudFront and S3 using Terraform

Over the years, I have used AWS Route 53, CloudFront, and S3 to deploy single-page web apps (SPA). Most of the time the backend API is delivered alongside the web app. This has a lot of advantages:

  • Eliminates CORS issues
  • Provides superfast delivery of the web app via CloudFront’s CDN
  • CloudFront may provide faster access to your API than connecting from the browser/app to an AWS region. This is unintuitive, but if the CloudFront edge node is closer to your browser, there will be less latency. After that, you’ll take advantage of the larger pipes going from CloudFront to the AWS region - possibly with fewer hops. Without CloudFront, your browser API request must travel over the public internet to reach the AWS region where your API is hosted.

Older Approaches

In the earlier AWS days, you might have deployed a SPA directly to S3 as a website in a public S3 bucket. It is possible to point Route 53 or CloudFront directly to such a bucket. But now we have learned that buckets should be kept private. Also, if you point Route 53 directly to S3, you will need a different subdomain for your API.

Read more
post-image

Finally, an Updated Site

The vscorp.com website has been sorely lacking attention since 2008! I’ve been busy working on interesting stuff and the site didn’t seem like a priority, so it gathered dust. Now, finally, we have updated the site with a new look and new content. We now also have a company blog where we’ll post things of interest as they come up.

Read more