0

I am looking at using AWS to host the website for my personal business. The website is simple and (currently) does not require a server. My website is written in React and does have some npm packages installed and also uses a router to navigate to other pages on my site.

Will an S3 bucket host a website that has routes and dependencies? What if my site grows and I eventually need a server. Will I be able to attach an EC2 instance to my site?

tdammon
  • 610
  • 2
  • 13
  • 39

1 Answers1

0

Option 1: Take a look at AWS Amplfiy as it might manage everything for you in Option 2 and super easy to get started. I use this for several website. Usually only takes minutes to get working if you already have an AWS account.

In short, from the AWS Console you can connect your app from GitHub, BitBucket, GitLab, and AWS CodeCommit. It usually will auto detect the type of project you have.

Amplify will create a managed S3 bucket and setup CloudFront you. It also registers a webwook with GIT so whenever you commit on a specific branch will rebuild and publish your site. You can even have multiple branch so www.acme.com -> master and working.acme.com -> branch

Option 2:

S3 <--- CloudFront <-- Lambda@Edge <-- Browser EC2 <--|

  • Store you file in S3
  • Use CloudFront (Content Delivery Network)
  • Create a Lambda@Edge to handle your routing.

Then in the future you can an EC2 server.

Look at the answer for the Lambda@Edge Multiple Cloudfront Origins with Behavior Path Redirection

WaltDe
  • 1,715
  • 8
  • 17
  • Thank you! Do I need to do anything special with my node_modules or my package.json? Will the S3 bucket be able to run `npm install` – tdammon Jan 31 '20 at 17:10
  • On second thought, also look Option 1 which I just updated. – WaltDe Jan 31 '20 at 17:21
  • Thanks Walt! I will check this out tonight. I've used Heroku before to deploy and manage sites but those sites always end up with quite a bit of latency. Is the same latency expected with Amplify? – tdammon Jan 31 '20 at 17:53
  • It should be a lot faster then Heroku because you are just serving static files compared to Heroku being an application server. I testing a couple of my sites with https://tools.pingdom.com/ from a couple of locations. I'll give you worse case I saw. My data is served out Ohio and I tested Australia. First time took 2.5 seconds to load. However, the second time it only took 286 ms because the Cloudfront edge network cached my files. – WaltDe Jan 31 '20 at 20:47