From 8d21b0fb4ec88c66c8de1afd19fcf2dc4604cc13 Mon Sep 17 00:00:00 2001 From: Chuck Budzeak Date: Tue, 11 Jan 2022 12:37:02 -0500 Subject: [PATCH] Add variables for task and container CPU and memory --- container-definitions.tpl | 4 ++-- ecs.tf | 6 ++++-- variables.tf | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/container-definitions.tpl b/container-definitions.tpl index 2d0d5ec..9f40850 100644 --- a/container-definitions.tpl +++ b/container-definitions.tpl @@ -2,8 +2,8 @@ { "name": "gh-runner-${gh_name_hash}", "image": "${ecr_repo_url}:${ecr_repo_tag}", - "cpu": 128, - "memory": 1024, + "cpu": ${container_cpu}, + "memory": ${container_memory}, "essential": true, "portMappings": [], "environment": [ diff --git a/ecs.tf b/ecs.tf index 66827b3..ad99a5d 100644 --- a/ecs.tf +++ b/ecs.tf @@ -194,12 +194,14 @@ resource "aws_ecs_task_definition" "runner_def" { task_role_arn = aws_iam_role.task_role.arn requires_compatibilities = ["FARGATE"] - cpu = "256" - memory = "1024" + cpu = var.task_cpu + memory = var.task_memory execution_role_arn = aws_iam_role.task_role.arn container_definitions = templatefile("${path.module}/container-definitions.tpl", { + container_cpu = var.container_cpu, + container_memory = var.container_memory, gh_name_hash = local.gh_name_hash, ecr_repo_url = var.ecr_repo_url, ecr_repo_tag = var.ecr_repo_tag, diff --git a/variables.tf b/variables.tf index 3fe00c7..32f30d1 100644 --- a/variables.tf +++ b/variables.tf @@ -83,4 +83,28 @@ variable "permissions_boundary" { description = "ARN of the policy that is used to set the permissions boundary for the role" type = string default = "" +} + +variable "task_cpu" { + description = "The ECS Task CPU size" + type = number + default = 256 +} + +variable "task_memory" { + description = "The ECS Task memroy size" + type = number + default = 1024 +} + +variable "container_cpu" { + description = "The container CPU size" + type = number + default = 128 +} + +variable "container_memory" { + description = "The container memroy size" + type = number + default = 1024 } \ No newline at end of file