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).
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"
}
}
}
No requirements.
No providers.
No modules.
No resources.
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({ |
n/a | yes |
essential | If the container is essential | bool |
n/a | yes |
health_check | The health check for the container | object({ |
null |
no |
image | The image to use for the container | string |
n/a | yes |
linux_parameters | The linux parameters for the container | object({ |
null |
no |
log_configuration | The log configuration for the container | object({ |
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({ |
null |
no |
name | The name of the container | string |
n/a | yes |
port_mappings | The port mappings for the container | list(object({ |
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({ |
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({ |
null |
no |
Name | Description |
---|---|
json_encoded | n/a |
json_encoded_list | n/a |