I am trying to make a portfolio-building app on aws. I am using reactjs for the front end, lambda(nodejs) for the backend, and other various technologies like dynamodb and API Gateway. My question is, how do I get the react content served up every time someone goes to my domain name? Is it done through lambda? Do I need an ec2 instance? I am stuck on this and if someone can help me out I would really appreciate it. Thanks!
2 Answers
There are many approaches you could use to set this up, it depends on what type or architecture you are looking for. I prefer to use AWS lambda functions attached to the API gateway for backend How To Build Your First Serverless API with AWS Lambda and API Gateway, and for frontend host the react.js app in s3 through cloudfront. This setup means that your entire application is serverless and you will be hard pressed to make it out of the free tier on AWS. Here is a great blog article detailing how to set this up Deploying create-react-app to S3 and CloudFront

- 1,273
- 9
- 13
-
Thanks @Eph Harris. Really appreciate it! – matt May 07 '20 at 15:35
-
no problem @matt, if you have any issues getting the react app to run in cloudfront, here are some of the most common fixes https://stackoverflow.com/a/61660051/10221416 – Ethan Harris May 07 '20 at 16:37
So where is your front end running?
It could be many locations:
- EC2 instance
- Elastic Beanstalk (either as a Node app, or as a Docker container)
- ECS/EKS (with or without Fargate)
- As a series of Lambdas (running behind an ALB)
Without knowing your application and experience of AWS services it's quite hard to advise exactly where you should host it. However, once you decide which one of these you are using you can points its target A record/CNAME at your domain name by editing the A record/CNAME in your hosting provider.

- 32,215
- 4
- 30
- 68