maddy23
maddy23

Reputation: 168

how to deploy backend and frontend app in ecs?

I have dockersied our webapp into two different docker files, such as: 1.Frontend 2.Backend

Both docker apps have their own .env files , i have to defined deployed server Ip address to connect them.

In frontend-env : configure backend ip

but deploying in ECS service, each container will be different ip ,how to solve this issue scale out and still connect the service each other.

so far :

  1. Create spreate ecs cluster for both frontend and backend, with ALB.
  2. Give the ALB in env files to connect them or hit the api.

any other solutions for this deployment?

Upvotes: 1

Views: 6660

Answers (1)

mreferre
mreferre

Reputation: 6053

You should be using Service Discovery to achieve this. You can read the announcement blog here. In a nutshell the way it works is that if you have two ECS services frontend and backend you want to expose frontend with an ALB for public access but enabling service discovery you will be able to have all tasks that belong to frontend to be able to connect to the tasks that belong to backend by calling backend.<domain> (where is the SD namespace you defined). When you do so ECS Service Discovery will resolve backend.<domain> to the private IP addresses of the tasks in backend thus eliminating the need for a load balancer in front of it.

If you want a practical example of how this works you can investigate this basic demo app:

enter image description here

Upvotes: 4

Related Questions