From 61d086719b13e580c774a17a1f115e07807eeeae Mon Sep 17 00:00:00 2001 From: Kaustubh Poshiya Date: Wed, 22 Jan 2025 14:51:04 +0530 Subject: [PATCH 1/2] feat: add runtime platform support --- main.tf | 9 +++++++++ variables.tf | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/main.tf b/main.tf index e9ab21e..38d0f0a 100644 --- a/main.tf +++ b/main.tf @@ -62,4 +62,13 @@ resource "aws_ecs_task_definition" "task" { } } } + + dynamic "runtime_platform" { + for_each = var.runtime_platform != null ? [var.runtime_platform] : [] + + content { + operating_system_family = runtime_platform.value.operating_system_family + cpu_architecture = runtime_platform.value.cpu_architecture + } + } } diff --git a/variables.tf b/variables.tf index b3149de..089bd3a 100644 --- a/variables.tf +++ b/variables.tf @@ -75,3 +75,12 @@ variable "ephemeral_storage_size" { type = number default = null } + +variable "runtime_platform" { + description = "The operating system family and the CPU architecture to use for the task. The valid values for operatingSystemFamily are WINDOWS and LINUX. The valid values for cpuArchitecture are X86_64 and ARM64." + type = object({ + operating_system_family = string + cpu_architecture = string + }) + default = null +} \ No newline at end of file From b82432cc4fcacca1a8f79d002d961e8f64ef1ede Mon Sep 17 00:00:00 2001 From: Kaustubh Poshiya Date: Wed, 22 Jan 2025 15:46:07 +0530 Subject: [PATCH 2/2] chore: updated example and readme file --- EXAMPLE.md | 20 ++++++++++++++++++++ README.md | 1 + 2 files changed, 21 insertions(+) diff --git a/EXAMPLE.md b/EXAMPLE.md index ae20866..36ab765 100644 --- a/EXAMPLE.md +++ b/EXAMPLE.md @@ -16,3 +16,23 @@ module "ecs_task_definition" { } ``` +## Create ECS Task Definition with specified runtime platform +If `runtime_platform` variable is not passed default os will be `LINUX` and architecture will be `X86_64` +``` +module "ecs_task_definition" { + source = "git::https://github.com/TechHoldingLLC/terraform-aws-ecs-task-definition.git?ref=v1.0.8" + + name = "demo-ecs-task-definition" + task_cpu = 256 + task_memory = 512 + + container_definitions = [module.con_def_1.container_definition, module.con_def_2.container_definition] + + #If variable is not passed default os will be `LINUX` and architecture will be `X86_64` + runtime_platform = { + operating_system_family = "LINUX" + cpu_architecture = "ARM64" + } +} +``` + diff --git a/README.md b/README.md index 09a4bd3..5912d12 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ No modules. | [name](#input\_name) | ECS task definition name | `string` | n/a | yes | | [network\_mode](#input\_network\_mode) | Docker networking mode to use for the containers in the task. The valid values are none, bridge, awsvpc, and host. | `string` | `"awsvpc"` | no | | [requires\_compatibilities](#input\_requires\_compatibilities) | A set of launch types required by the task. The valid values are EC2 and FARGATE. | `list(string)` |
[
"FARGATE"
]
| no | +| [runtime\_platform](#input\_runtime\_platform) | The operating system family and the CPU architecture to use for the task. The valid values for operatingSystemFamily are WINDOWS and LINUX. The valid values for cpuArchitecture are X86\_64 and ARM64. |
object({
operating_system_family = string
cpu_architecture = string
})
| `null` | no | | [ssm\_kms\_alias](#input\_ssm\_kms\_alias) | SSM kms key alias | `string` | `"alias/aws/ssm"` | no | | [task\_cpu](#input\_task\_cpu) | ECS fargate task cpu | `number` | n/a | yes | | [task\_memory](#input\_task\_memory) | ECS fargate task memory | `number` | n/a | yes |