karanpratapsingh / preview-environments

Quickly create temporary preview environments
MIT License
14 stars 4 forks source link

Support for multiple preview environments under different sub domains #12

Open chris-hinds opened 1 year ago

chris-hinds commented 1 year ago

Hi, this looks great. Was wondering if this supports multiple branches. being pushed i.e. a preview env per branch each on a different subdomain.

From what I can see this will just work until one single domain currently.

karanpratapsingh commented 1 year ago

Hi @chris-hinds, yes this supports N different subdomains.

For example,

feat/branch-x ----> feat-branch-x.domain.com
feat/branch-y ----> feat-branch-y.domain.com
chris-hinds commented 1 year ago

Thanks, @karanpratapsingh are you pointing the Cloudflare domains to a load balancer in front of ECS? Or directly to the VPC? If so how do the subdomains know which ECS task to point to?

Apologies if I missed where this logic is.

karanpratapsingh commented 1 year ago

Traffic from the ECS tasks is proxied to Cloudflare DNS using Cloudflare Argo tunnels. So, ECS service can run in private subnet without exposing to internet unsafely

chris-hinds commented 1 year ago

@karanpratapsingh How could this be hooked into an ECS Service? I mostly have this working but I am using a load balancer that requires an ECS service.

I have the scripts launching a task however as it is not part of the service it doesn't get associated with the load balancer.

My thinking is that I need to create a new service + target group for every PR and then a new rule in the load balancer each time a service is added or removed