Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

modernisation-platform-terraform-ecs//service

Releases

This module is used to deploy an ECS Service and/or task definitions onto an ECS Cluster.

Usage example

module "ecs_service" {
  source                = "git::https://github.com/ministryofjustice/modernisation-platform-terraform-ecs-cluster//service"

  container_definitions = module.container_definition.json_map_encoded_list
  cluster_arn           = var.ecs_cluster_arn
  name                  = var.name

  task_cpu    = var.container_cpu
  task_memory = var.container_memory

  desired_count                      = var.desired_count
  deployment_maximum_percent         = var.deployment_maximum_percent
  deployment_minimum_healthy_percent = var.deployment_minimum_healthy_percent

  service_role_arn   = "arn:aws:iam::${var.account_info.id}:role/${module.ecs_policies.service_role.name}"
  task_role_arn      = "arn:aws:iam::${var.account_info.id}:role/${module.ecs_policies.task_role.name}"
  task_exec_role_arn = "arn:aws:iam::${var.account_info.id}:role/${module.ecs_policies.task_exec_role.name}"

  health_check_grace_period_seconds = var.health_check_grace_period_seconds

  service_load_balancers = [
    {
      target_group_arn = aws_lb_target_group.frontend.arn
      container_name   = var.name
      container_port   = var.container_port_config[0].containerPort
    }
  ]

  efs_volumes = var.efs_volumes

  security_groups = [aws_security_group.ecs_service.id]

  subnets = var.account_config.private_subnet_ids

  enable_execute_command = true

  ignore_changes = false

  tags = var.tags
}

Requirements

No requirements.

Providers

Name Version
aws n/a

Modules

No modules.

Resources

Name Type
aws_ecs_service.default resource
aws_ecs_service.ignore_changes resource
aws_ecs_task_definition.default resource
aws_ecs_task_definition.ignore_changes resource

Inputs

Name Description Type Default Required
cluster_arn The ARN of the ECS cluster string n/a yes
container_definitions The JSON formatted container definition string n/a yes
deployment_circuit_breaker The deployment circuit breaker configuration
object({
enable = bool
rollback = bool
})
{
"enable": false,
"rollback": false
}
no
deployment_maximum_percent The upper limit (as a percentage of the service's desiredCount) of the number of running tasks that can be running in a service during a deployment number 200 no
deployment_minimum_healthy_percent The lower limit (as a percentage of the service's desiredCount) of the number of running tasks that must remain running and healthy in a service during a deployment number 100 no
desired_count The number of instances of the task definition to place and keep running number 1 no
efs_volumes n/a
list(object({
host_path = string
name = string
efs_volume_configuration = list(object({
file_system_id = string
root_directory = string
transit_encryption = string
transit_encryption_port = string
authorization_config = list(object({
access_point_id = string
iam = string
}))
}))
}))
[] no
enable_execute_command Whether to enable the execute command functionality on the service bool false no
ephemeral_storage_size_in_gib The size of the ephemeral storage to use for the task definition number 30 no
force_new_deployment Whether to force a new deployment of the service bool false no
health_check_grace_period_seconds The grace period to allow for healthy instances to warm up before checking them number 0 no
ignore_changes Whether to ignore changes to the service, task definition, container definition bool n/a yes
name The name of the ECS service string n/a yes
security_groups A list of security group IDs to associate with the service list(string) n/a yes
service_load_balancers A list of load balancers to associate with the service
list(object({
container_name = string
container_port = number
elb_name = optional(string)
target_group_arn = string
}))
n/a yes
service_role_arn The ARN of the IAM role to use for the service string n/a yes
subnets A list of subnet IDs to launch the service in list(string) n/a yes
tags A map of tags to add to all resources map(string) {} no
task_cpu The amount of CPU to use for the task definition string "256" no
task_exec_role_arn The ARN of the IAM role to use for the execution string n/a yes
task_memory The amount of memory to use for the task definition string "512" no
task_role_arn The ARN of the IAM role to use for the task string n/a yes
wait_for_steady_state Whether to wait for the service to reach a steady state before reporting success bool false no

Outputs

Name Description
service_arn The ARN for the ECS Service
task_definition_arn The ARN for the ECS Task Definition
task_definition_string The JSON formatted container definition