Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable to configure container_definitions cpu and memory #89

Open
Anthony-Michel opened this issue Sep 5, 2023 · 0 comments
Open

Comments

@Anthony-Michel
Copy link

Anthony-Michel commented Sep 5, 2023

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant