Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

modernisation-platform-terraform-ecs//container

Releases

This module creates an ECS container definition.

It takes in a number of inputs (see TFDocs below) and outputs a container definition that can be used in an ECS task definition. It outputs the container definition as a JSON string as well as a list so that multiple containers can be defined in a single task definition (call this module many times and concat the list outputs).

Usage example

module "container_definition" {
  source                   = "git::https://github.com/ministryofjustice/modernisation-platform-terraform-ecs-cluster//container?ref=v4.2.0"
  name                     = "my-container"
  image                    = "nginx:latest"
  memory                   = 512
  cpu                      = 256
  essential                = true
  readonly_root_filesystem = false

  environment = [
    {
      name  = "ENV_VAR"
      value = "value"
    },
    {
      name  = "ENV_VAR_2"
      value = "value"
    }
  ]

  secrets = [
    {
      name      = "SECRET_NAME
      valueFrom = "arn:aws:ssm:eu-west-2:123456789012:parameter/secret"
    },
    {
      name      = "SECRET_NAME_2"
      valueFrom = "arn:aws:ssm:eu-west-2:123456789012:parameter/secret"
    }
  ]
  port_mappings = [
    {
      containerPort = 80
      hostPort      = 80
    }
  ]
  mount_points = [
    {
      sourceVolume  = "volume"
      containerPath = "/var/www/html"
      readOnly      = false
    }
  ]
  log_configuration = {
    logDriver = "awslogs"
    options = {
      "awslogs-group"         = aws_cloudwatch_log_group.ecs.name
      "awslogs-region"        = "eu-west-2"
      "awslogs-stream-prefix" = "nginx"
    }
  }
}

Requirements

No requirements.

Providers

No providers.

Modules

No modules.

Resources

No resources.

Inputs

Name Description Type Default Required
command The command for the container list(string) null no
cpu The number of cpu units to reserve for the container number null no
entry_point The entry point for the container list(string) null no
environment The environment for the container
list(object({
name = string
value = string
}))
n/a yes
essential If the container is essential bool n/a yes
health_check The health check for the container
object({
command = list(string)
interval = number
timeout = number
retries = number
startPeriod = number
})
null no
image The image to use for the container string n/a yes
linux_parameters The linux parameters for the container
object({
capabilities = object({
add = list(string)
drop = list(string)
})
initProcessEnabled = bool
})
null no
log_configuration The log configuration for the container
object({
logDriver = string
options = map(string)
})
n/a yes
memory The amount of memory (in MiB) to reserve for the container number null no
mount_points The mount points for the container
list(object({
sourceVolume = string
containerPath = string
readOnly = bool
}))
null no
name The name of the container string n/a yes
port_mappings The port mappings for the container
list(object({
containerPort = number
hostPort = optional(number, null)
protocol = string
}))
n/a yes
readonly_root_filesystem If the container has a readonly root filesystem bool n/a yes
secrets The secrets for the container
list(object({
name = string
valueFrom = string
}))
n/a yes
start_timeout The start timeout for the container number null no
stop_timeout The stop timeout for the container number null no
system_controls The system controls for the container
list(object({
namespace = string
value = string
}))
null no

Outputs

Name Description
json_encoded n/a
json_encoded_list n/a

Reading Material