Skip to content

Commit

Permalink
Add variables for task and container CPU and memory
Browse files Browse the repository at this point in the history
  • Loading branch information
crbudzeak committed Jan 11, 2022
1 parent 3db94a9 commit 8d21b0f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions container-definitions.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
6 changes: 4 additions & 2 deletions ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 24 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 8d21b0f

Please sign in to comment.