Search code examples
amazon-web-servicesamazon-ecs

Two clusters with same task, container and service names?


I am thinking of creating two clusters: live and staging. Will AWS treat defined tasks, containers and services inside the two clusters as distinct or will they collide in some regards?

Example:

live cluster has a service called login-service, can staging cluster have a service called login-service too or would it be better to call the services login-live-service and login-staging-service?


Solution

  • As long as the two clusters are not sharing any resources they should not collide in any way. Resources could include load balancers, gateways and VPC's. In theory, you could share some resources and even instances if you need to save costs but you would need to change ports and configure your load balancer appropriately.

    The task definitions might need different environment variables, in which case I would create different task definitions for each environment. You can set environment variables at run time when calling the StartTask and RunTask ecs API calls as well as some services, in that case you could share a single task definition.

    If you are using cloudformation with amazon ecs then you should be able to setup a different VPC and ELB/ALB for each cluster using a cloudformation template. The ecs-cli repo has a sample template you can pry out - see https://github.com/aws/amazon-ecs-cli.