Skip to content

Variable to configure container_definitions cpu and memory #89

@Anthony-Michel

Description

@Anthony-Michel

Feature request

How can we improve the module?
I'm running an ASP.Net in ECS and as highlighted in this article https://aws.amazon.com/blogs/developer/configuring-net-garbage-collection-for-amazon-ecs-and-aws-lambda/ i need to set the container CPU and memory size to avoid OOM.
hence i would need to either be able to inject those cpu and memory values to the container_definiton
container_definitions = jsonencode([
{
name = "first"
image = "service-first"
cpu = 10
memory = 512
essential = true
portMappings = [
{
containerPort = 80
hostPort = 80
}
]
}

or at least have those values set by default with the values configured at the task_definition level
Code to be updated for default being same as task_defintion :

container_definition = merge({
"name"             = var.container_name != "" ? var.container_name : var.name_prefix
"image"            = var.task_container_image,
"essential"        = true
"cpu"                = var.task_definition_cpu
"memory"        = var.task_definition_memory
"portMappings"     = local.task_container_port_mappings
"stopTimeout"      = var.stop_timeout
"command"          = var.task_container_command
"environment"      = local.task_container_environment
"environmentFiles" = var.task_container_environment_file
"MountPoints"      = local.task_container_mount_points
"logConfiguration" = {
  "logDriver" = "awslogs"
  "options"   = local.log_configuration_options
}
"privileged" : var.privileged
"readonlyRootFilesystem" : var.readonlyRootFilesystem
}, local.task_container_secrets, local.repository_credentials)

And solution with new specific variable :

container_definition = merge({
"name"             = var.container_name != "" ? var.container_name : var.name_prefix
"image"            = var.task_container_image,
"essential"        = true
"cpu"                = var.container_cpu
"memory"        = var.container_memory
"portMappings"     = local.task_container_port_mappings
"stopTimeout"      = var.stop_timeout
"command"          = var.task_container_command
"environment"      = local.task_container_environment
"environmentFiles" = var.task_container_environment_file
"MountPoints"      = local.task_container_mount_points
"logConfiguration" = {
  "logDriver" = "awslogs"
  "options"   = local.log_configuration_options
}
"privileged" : var.privileged
"readonlyRootFilesystem" : var.readonlyRootFilesystem
}, local.task_container_secrets, local.repository_credentials)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions