cn-terraform / terraform-aws-ecs-fargate

AWS ECS Fargate Terraform Module
https://registry.terraform.io/modules/cn-terraform/ecs-fargate
Apache License 2.0
87 stars 56 forks source link

Question, Multiple services in one cluster #85

Closed dvreggionx closed 1 year ago

dvreggionx commented 1 year ago

Hi, maybe someone can help me with this, i am tyring to use this module but i need to deploy 2 services in the same cluster, I am using this tf file, do you know if is possible with this module? thanks, sorry for the noob question

`module "base-network" { source = "cn-terraform/networking/aws" name_prefix = "test-networking" vpc_cidr_block = "192.168.0.0/16" availability_zones = ["us-east-1a", "us-east-1b"] public_subnets_cidrs_per_availability_zone = ["192.168.0.0/19", "192.168.32.0/19"] private_subnets_cidrs_per_availability_zone = ["192.168.128.0/19", "192.168.160.0/19"] }

module "test" { source = "../../" name_prefix = "test" vpc_id = module.base-network.vpc_id container_image = "nginx" container_name = "test" container_cpu = 256 container_memory = 512 container_memory_reservation = 512 enable_s3_logs = "false" lb_target_group_health_check_path = "/" port_mappings = [ { "containerPort": 443, "hostPort": 443, "protocol": "tcp" }, { "containerPort": 80, "hostPort": 80, "protocol": "tcp" } ] public_subnets_ids = module.base-network.public_subnets_ids private_subnets_ids = module.base-network.private_subnets_ids default_certificate_arn = "arn:aws:acm:us-east-1***" } `

jnonino commented 1 year ago

Hi @dvreggionx, I'll recommend using something like this:

module "base-network" {
  source  = "cn-terraform/networking/aws"
  version = "2.0.16"
  ...
}

module "ecs-cluster" {
  source  = "cn-terraform/ecs-cluster/aws"
  version = "1.0.10"
  ...
}

module "td_1" {
  source  = "cn-terraform/ecs-fargate-task-definition/aws"
  version = "1.0.33"
  ...
}

module "ecs-fargate-service_1" {
  source  = "cn-terraform/ecs-fargate-service/aws"
  version = "2.0.41"
}

module "td_2" {
  source  = "cn-terraform/ecs-fargate-task-definition/aws"
  version = "1.0.33"
  ...
}

module "ecs-fargate-service_2" {
  source  = "cn-terraform/ecs-fargate-service/aws"
  version = "2.0.41"
}
dvreggionx commented 1 year ago

thank you very much for your response i am going to try with that workaround