I have deployed a Load Balanced Web Service in a copilot application. After deploying it, I added a new HTTPS / 443 listener that forwards requests to the Target Group where the ECS container is deployed:
name: api1
type: Load Balanced Web Service
http:
path: 'api1'
When I go to https://my-domain.com/api1, the requests go to my ECS container, all good.
Now I want to add a second Load Balanced Web Service:
name: api2
type: Load Balanced Web Service
http:
path: 'api2'
When I deploy it, it gets created into another Target Group and when I do https://my-domain.com/api2 the requests go to the first container (api1). I tried adding the 2nd target group to the "Forward To" rule of the Https listener, but then the requests get redirected randomly between both and I get 503 errors most of the time.
What is the correct way to deploy 2 load balanced web service within the same app? I just want to have https://my-domain.com/api1 => api1 container https://my-domain.com/api2 => api2 container
So I finally found the solution, I had to do on the Load Balancer:
/api2
It would be nice to be able to do this from the copilot config but it works now