AWS ECS architecture AWS ECS architecture docker docker

AWS ECS architecture


  1. How can I expose the react app to the outside world? should I use Internet gateway or ELB/ALB? what are the differences?

If react frontend is static website, then probably would be best to use S3 + CloudFront for hosting it. But if you want to use ECS, then yes, using internet facing load balancer is how it is usually done.

ELB is first generation of load balancers. These days you should use ALB with is second generation balancer which provide many more features then ELB, e.g. redirection from http to https.

Internet gateway is for your VPC, its only needed if you use custom destined VPC. If you use default VPC, then you don't have to worry about it.

  1. How do I make the react app talk to the server when the server only have private IP? Service discovery? And if so, how should I inject the server's service name to the react app using docker?

You can't use private IP nor service discovery. Your frontend will execute in your clients browser so it has to use internet to talk with your backend. This means you need to expose your Flask API using public IP, not private.

This again could be done using public ALB. You could use the same ALB as for the front-end. So you would have the following setup:

                                   |---> Target Group 1 ---> ECS Services for React frontend (private subnet)Client ---> ALB (public subnet) ---|                                   |---> Target Group 2 ---> ECS Service for Flask (private subnet)