This module was created to create a fargate service cluster
Terraform's remote state definition is a must to avoid hardcoding. The ECS Cluster, Task definition and Load Balancer are needed.
This module only deploy a fargate cluster services and load balancer logic.
module "ecs_service" {
source = "[email protected]:calibers/terraform-aws-ecs-fargate-service.git?ref=v1.0"
fargate_services = {
service_name = "service-name"
task_definition_arn = data.terraform_remote_state.ecs-task.outputs.aws_ecs_task_definition_td_arn
service_desired_count = var.environment == "prd" ? 3 : 1
lb_config = [
{
target_group_arn = data.terraform_remote_state.ecs-lb.outputs.target_group_arn
container_name = var.container_name
container_port = 4000
}
]
}
cluster_id = data.terraform_remote_state.ecs-cluster.outputs.fargate_id
cluster_name = "${var.environment}-${var.service_name}-ecs"
security_group_ids = data.terraform_remote_state.ecs-cluster.outputs.fargate_sg_ids
subnet_ids = data.terraform_remote_state.vpc.outputs.public_subnets
enable_autoscaling = true
tags = {
Environment = var.environment
}
}
Name | Description | Type | Default | Required |
---|---|---|---|---|
cluster_id | Cluster id where you need to create services | string | - | yes |
cluster_name | Name of the Cluster where you need to create services | string | - | yes |
fargate_services | Define fargate service information | map | {} |
no |
security_group_ids | List of security groups ids we need to add this cluster service | list | [] |
no |
subnet_ids | private subnet ids | list(string) | - | no |
enable_autoscaling | Enable or disable autoscaling config | bool | - | yes |
target_group_arn | ARN of the load balancer's target group | string | - | yes |
container_name | Name of the task's container | string | - | yes |
container_port | port of the task's container | number | - | yes |
task_definition_arn | Task definition arn | string | - | yes |
tags | A amount of tags added as a map | map | - | yes |
Name | Description |
---|---|
service_name | Name of the service we created |