From de6e99adac447e5720d05b773c5a5674d9336047 Mon Sep 17 00:00:00 2001 From: Yousif Akbar <11247449+yhakbar@users.noreply.github.com> Date: Wed, 2 Nov 2022 09:11:39 -0400 Subject: [PATCH 1/4] Adding ARM support --- README.md | 5 ++-- cluster.tf | 2 +- examples/am/.terraform.lock.hcl | 26 ++++++++-------- examples/am/main.tf | 10 +++---- examples/arm/.gitignore | 2 ++ examples/arm/.terraform.lock.hcl | 22 ++++++++++++++ examples/arm/main.tf | 14 +++++++++ examples/arm/outputs.tf | 3 ++ examples/arm/sample-backend.tf | 9 ++++++ examples/arm/sample-provider.tf | 12 ++++++++ examples/arm/tags.tf | 45 ++++++++++++++++++++++++++++ examples/arm/vars.tf | 4 +++ examples/basic/.terraform.lock.hcl | 27 ++++++++--------- examples/efs/.terraform.lock.hcl | 26 ++++++++-------- examples/image/.terraform.lock.hcl | 26 ++++++++-------- examples/nlb/.terraform.lock.hcl | 26 ++++++++-------- examples/no-lb/.terraform.lock.hcl | 26 ++++++++-------- examples/private/.terraform.lock.hcl | 26 ++++++++-------- examples/sgs/.terraform.lock.hcl | 26 ++++++++-------- optional-task.tf | 12 ++++++++ task.tf | 4 ++- tests/arm_test.go | 9 ++++++ tests/utilities_ecs_service.go | 19 ++++++++++-- 23 files changed, 263 insertions(+), 118 deletions(-) create mode 100644 examples/arm/.gitignore create mode 100644 examples/arm/.terraform.lock.hcl create mode 100644 examples/arm/main.tf create mode 100644 examples/arm/outputs.tf create mode 100644 examples/arm/sample-backend.tf create mode 100644 examples/arm/sample-provider.tf create mode 100644 examples/arm/tags.tf create mode 100644 examples/arm/vars.tf create mode 100644 tests/arm_test.go diff --git a/README.md b/README.md index bda92cd..01b3378 100644 --- a/README.md +++ b/README.md @@ -74,8 +74,8 @@ Below is automatically generated documentation on this Terraform module using [t | Name | Source | Version | |------|--------|---------| -| [cluster](#module\_cluster) | github.com/pbs/terraform-aws-ecs-cluster-module | 0.0.1 | -| [task](#module\_task) | github.com/pbs/terraform-aws-ecs-task-definition-module | 0.1.1 | +| [cluster](#module\_cluster) | github.com/pbs/terraform-aws-ecs-cluster-module | 0.0.2 | +| [task](#module\_task) | github.com/pbs/terraform-aws-ecs-task-definition-module | 0.2.0 | ## Resources @@ -197,6 +197,7 @@ Below is automatically generated documentation on this Terraform module using [t | [restricted\_cidr\_blocks](#input\_restricted\_cidr\_blocks) | CIDR blocks to receive restricted service access. If empty, no CIDRs will be allowed to connect. | `list(string)` |
[| no | | [restricted\_sg](#input\_restricted\_sg) | SG to receive restricted service access. If null, no sg will be configured to connect | `string` | `null` | no | | [role\_policy\_json](#input\_role\_policy\_json) | the policy to apply for this service. Defaults to a valid ECS role policy if null. | `string` | `null` | no | +| [runtime\_platform](#input\_runtime\_platform) | (optional) Runtime platform for the task. Defaults to LINUX operating system family w/ CPU architecture x86\_64. |
"0.0.0.0/0"
]
object({|
operating_system_family = optional(string, "LINUX")
cpu_architecture = optional(string, "X86_64")
})
{| no | | [scale\_down\_adjustment](#input\_scale\_down\_adjustment) | Tasks to add on scale up | `number` | `-1` | no | | [scale\_down\_cooldown](#input\_scale\_down\_cooldown) | Scale down cooldown in minutes | `number` | `5` | no | | [scale\_down\_cpu\_threshold](#input\_scale\_down\_cpu\_threshold) | Threshold at which CPU utilization triggers a scale down event | `number` | `20` | no | diff --git a/cluster.tf b/cluster.tf index 9a3538c..60f28ff 100644 --- a/cluster.tf +++ b/cluster.tf @@ -1,6 +1,6 @@ module "cluster" { count = var.cluster == null ? 1 : 0 - source = "github.com/pbs/terraform-aws-ecs-cluster-module?ref=0.0.1" + source = "github.com/pbs/terraform-aws-ecs-cluster-module?ref=0.0.2" organization = var.organization environment = var.environment diff --git a/examples/am/.terraform.lock.hcl b/examples/am/.terraform.lock.hcl index 63304ce..4459bb1 100644 --- a/examples/am/.terraform.lock.hcl +++ b/examples/am/.terraform.lock.hcl @@ -2,21 +2,21 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/hashicorp/aws" { - version = "4.5.0" + version = "4.37.0" constraints = ">= 4.5.0" hashes = [ - "h1:6y12cTFaxpFv4qyU3gkV9M15eSBBrgInoKY1iaHuhvg=", - "zh:0573de96ba316d808be9f8d6fc8e8e68e0e6b614ed4d707bd236c4f7b46ac8b1", - "zh:37560469042f5f43fdb961eb6e6b0a8f95057df68af2c1168d5b8c66ddcb1512", - "zh:44bb4f6bc1f58e19b8bf7041f981a2549a351762d17dd39654eb24d1fa7991c7", - "zh:53af6557b68e547ac5c02cfd0e47ef63c8e9edfacf46921ccc97d73c0cd362c9", - "zh:578a583f69a8e5947d66b2b9d6969690043b6887f6b574263be7ef05f82a82ad", - "zh:6c2d42f30db198a4e7badd7f8037ef9bd951cfd6cf40328c6a7eed96801a374e", - "zh:758f3fc4d833dbdda57a4db743cbbddc8fd8c0492df47771b848447ba7876ce5", - "zh:78241bd45e2f6102055787b3697849fee7e9c28a744ba59cad956639c1aca07b", + "h1:fLTymOb7xIdMkjQU1VDzPA5s+d2vNLZ2shpcFPF7KaY=", + "zh:12c2eb60cb1eb0a41d1afbca6fc6f0eed6ca31a12c51858f951a9e71651afbe0", + "zh:1e17482217c39a12e930e71fd2c9af8af577bec6736b184674476ebcaad28477", + "zh:1e8163c3d871bbd54c189bf2fe5e60e556d67fa399e4c88c8e6ee0834525dc33", + "zh:399c41a3e096fd75d487b98b1791f7cea5bd38567ac4e621c930cb67ec45977c", + "zh:40d4329eef2cc130e4cbed7a6345cb053dd258bf6f5f8eb0f8ce777ae42d5a01", + "zh:625db5fa75638d543b418be7d8046c4b76dc753d9d2184daa0faaaaebc02d207", + "zh:7785c8259f12b45d19fa5abdac6268f3b749fe5a35c8be762c27b7a634a4952b", + "zh:8a7611f33cc6422799c217ec2eeb79c779035ef05331d12505a6002bc48582f0", + "zh:9188178235a73c829872d2e82d88ac6d334d8bb01433e9be31615f1c1633e921", + "zh:994895b57bf225232a5fa7422e6ab87d8163a2f0605f54ff6a18cdd71f0aeadf", "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:a3a7f4699c097c7b8364d05a5df9f3bd5d005fd5736c28ec5dc8f8c0ee340512", - "zh:bf875483bf2ad6cfb4029813328cdcd9ea40f50b9f1c265f4e742fe8cc456157", - "zh:f4722596e8b5f012013f87bf4d2b7d302c248a04a144de4563b3e3f754a30c51", + "zh:b57de6903ef30c9f22d38d595d64b4f92a89ea717b65782e1f44f57020ce8b1f", ] } diff --git a/examples/am/main.tf b/examples/am/main.tf index 835208e..d615662 100644 --- a/examples/am/main.tf +++ b/examples/am/main.tf @@ -152,9 +152,8 @@ module "service_v1" { name = "${var.product}-v1" - mesh_name = module.mesh.id - virtual_node = "ex-service-v1" - virtual_service = module.virtual_service.name + mesh_name = module.mesh.id + virtual_node = "ex-service-v1" namespace = var.product namespace_id = module.namespace.id @@ -170,9 +169,8 @@ module "service_v2" { name = "${var.product}-v2" - mesh_name = module.mesh.id - virtual_node = "ex-service-v2" - virtual_service = module.virtual_service.name + mesh_name = module.mesh.id + virtual_node = "ex-service-v2" namespace = var.product namespace_id = module.namespace.id diff --git a/examples/arm/.gitignore b/examples/arm/.gitignore new file mode 100644 index 0000000..576a5c5 --- /dev/null +++ b/examples/arm/.gitignore @@ -0,0 +1,2 @@ +backend.tf +provider.tf diff --git a/examples/arm/.terraform.lock.hcl b/examples/arm/.terraform.lock.hcl new file mode 100644 index 0000000..4459bb1 --- /dev/null +++ b/examples/arm/.terraform.lock.hcl @@ -0,0 +1,22 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "4.37.0" + constraints = ">= 4.5.0" + hashes = [ + "h1:fLTymOb7xIdMkjQU1VDzPA5s+d2vNLZ2shpcFPF7KaY=", + "zh:12c2eb60cb1eb0a41d1afbca6fc6f0eed6ca31a12c51858f951a9e71651afbe0", + "zh:1e17482217c39a12e930e71fd2c9af8af577bec6736b184674476ebcaad28477", + "zh:1e8163c3d871bbd54c189bf2fe5e60e556d67fa399e4c88c8e6ee0834525dc33", + "zh:399c41a3e096fd75d487b98b1791f7cea5bd38567ac4e621c930cb67ec45977c", + "zh:40d4329eef2cc130e4cbed7a6345cb053dd258bf6f5f8eb0f8ce777ae42d5a01", + "zh:625db5fa75638d543b418be7d8046c4b76dc753d9d2184daa0faaaaebc02d207", + "zh:7785c8259f12b45d19fa5abdac6268f3b749fe5a35c8be762c27b7a634a4952b", + "zh:8a7611f33cc6422799c217ec2eeb79c779035ef05331d12505a6002bc48582f0", + "zh:9188178235a73c829872d2e82d88ac6d334d8bb01433e9be31615f1c1633e921", + "zh:994895b57bf225232a5fa7422e6ab87d8163a2f0605f54ff6a18cdd71f0aeadf", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:b57de6903ef30c9f22d38d595d64b4f92a89ea717b65782e1f44f57020ce8b1f", + ] +} diff --git a/examples/arm/main.tf b/examples/arm/main.tf new file mode 100644 index 0000000..d4eb9ba --- /dev/null +++ b/examples/arm/main.tf @@ -0,0 +1,14 @@ +module "service" { + source = "../.." + + primary_hosted_zone = var.primary_hosted_zone + + runtime_platform = { + cpu_architecture = "ARM64" + } + + organization = var.organization + environment = var.environment + product = var.product + repo = var.repo +} diff --git a/examples/arm/outputs.tf b/examples/arm/outputs.tf new file mode 100644 index 0000000..acbe6e1 --- /dev/null +++ b/examples/arm/outputs.tf @@ -0,0 +1,3 @@ +output "domain_name" { + value = module.service.domain_name +} diff --git a/examples/arm/sample-backend.tf b/examples/arm/sample-backend.tf new file mode 100644 index 0000000..7c187d2 --- /dev/null +++ b/examples/arm/sample-backend.tf @@ -0,0 +1,9 @@ +# terraform { +# backend "s3" { +# bucket = "my-bucket-tfstate" +# key = "example-terraform-aws-ecs-service-arm" +# profile = "my-profile" +# region = "us-east-1" +# dynamodb_table = "terraform-lock" +# } +# } diff --git a/examples/arm/sample-provider.tf b/examples/arm/sample-provider.tf new file mode 100644 index 0000000..f8c7957 --- /dev/null +++ b/examples/arm/sample-provider.tf @@ -0,0 +1,12 @@ +# provider "aws" { +# region = "us-east-1" +# profile = "my-profile" +# default_tags { +# tags = { +# product = var.product +# environment = var.environment +# repo = var.repo +# organization = var.organization +# } +# } +# } diff --git a/examples/arm/tags.tf b/examples/arm/tags.tf new file mode 100644 index 0000000..869105f --- /dev/null +++ b/examples/arm/tags.tf @@ -0,0 +1,45 @@ +variable "environment" { + description = "Environment (sharedtools, dev, staging, prod)" + type = string + + default = "sharedtools" + + validation { + condition = contains(["sharedtools", "dev", "staging", "prod"], var.environment) + error_message = "The environment variable must be one of [sharedtools, dev, staging, prod]." + } +} + +variable "product" { + description = "Tag used to group resources according to application" + + default = "example-tf-ecs-service-arm" + + validation { + condition = can(regex("[a-z\\-]+", var.product)) + error_message = "The product variable violates approved regex." + } +} + +variable "repo" { + description = "Tag used to point to the repo using this module" + + default = "https://github.com/pbs/terraform-ecs-service-module.git" + + validation { + condition = can(regex("(?:git|ssh|https?|git@[-\\w.]+):(\\/\\/)?(.*?)(\\.git)(\\/?|\\#[-\\d\\w._]+?)$", var.repo)) + error_message = "The repo variable violates approved regex." + } +} + +variable "organization" { + description = "Organization using this module. Used to prefix tags so that they are easily identified as being from your organization" + type = string + + default = "example" + + validation { + condition = can(regex("[a-z\\-]+", var.organization)) + error_message = "The organization variable violates approved regex." + } +} diff --git a/examples/arm/vars.tf b/examples/arm/vars.tf new file mode 100644 index 0000000..9364019 --- /dev/null +++ b/examples/arm/vars.tf @@ -0,0 +1,4 @@ +variable "primary_hosted_zone" { + type = string + description = "Primary hosted zone for this service. Populate `TF_VAR_primary_hosted_zone` before running any tests to have this value populated." +} diff --git a/examples/basic/.terraform.lock.hcl b/examples/basic/.terraform.lock.hcl index 67ed6bb..4459bb1 100644 --- a/examples/basic/.terraform.lock.hcl +++ b/examples/basic/.terraform.lock.hcl @@ -2,22 +2,21 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/hashicorp/aws" { - version = "4.26.0" + version = "4.37.0" constraints = ">= 4.5.0" hashes = [ - "h1:jt8jLpFFhaapdbBqw4WQpDuLN8y7zF8/iLyCzypDxSQ=", - "h1:q0QTY+O5L//LGGkmlUlEvTLnNSsdV91Tqm7BFqwpSII=", - "zh:0579b105ae471894846fbd740bc9f10b2bd8a48860d8e640b4a9b53fb7d63ffe", - "zh:0ce445cfbffb6c0eee9e0e2a95850b5749d56aa8211b95a686c24dc2847a36ea", - "zh:41f0cf0810363cea4e54f3d9c452f2eb77123bcdaacc18b978c825496168cae2", - "zh:431a7e967b5c9d7ebde6c714abedd9464be6a62f7eafa1808a86a8bd92851317", - "zh:4afebd3c3a8c0646f0874493840b6f8c82f7f4302780faec5c7b0c616077eebe", - "zh:7f077662efc8d7b91ef604999daf6b45a968cb2f5d8c4512a00d2feb4db05a7a", - "zh:9a58d1ef049ccaa9615fe5722ba815065f45d172f8bc656ffdbab4ca16f6b786", + "h1:fLTymOb7xIdMkjQU1VDzPA5s+d2vNLZ2shpcFPF7KaY=", + "zh:12c2eb60cb1eb0a41d1afbca6fc6f0eed6ca31a12c51858f951a9e71651afbe0", + "zh:1e17482217c39a12e930e71fd2c9af8af577bec6736b184674476ebcaad28477", + "zh:1e8163c3d871bbd54c189bf2fe5e60e556d67fa399e4c88c8e6ee0834525dc33", + "zh:399c41a3e096fd75d487b98b1791f7cea5bd38567ac4e621c930cb67ec45977c", + "zh:40d4329eef2cc130e4cbed7a6345cb053dd258bf6f5f8eb0f8ce777ae42d5a01", + "zh:625db5fa75638d543b418be7d8046c4b76dc753d9d2184daa0faaaaebc02d207", + "zh:7785c8259f12b45d19fa5abdac6268f3b749fe5a35c8be762c27b7a634a4952b", + "zh:8a7611f33cc6422799c217ec2eeb79c779035ef05331d12505a6002bc48582f0", + "zh:9188178235a73c829872d2e82d88ac6d334d8bb01433e9be31615f1c1633e921", + "zh:994895b57bf225232a5fa7422e6ab87d8163a2f0605f54ff6a18cdd71f0aeadf", "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:9d30b70a2daa0d94661590f6533e07071d2c7052b8279f05090f1bf037f56607", - "zh:b75f88be5d048849a632895d43b836ed1693031e586cd873ee915b5d3cf4fae6", - "zh:c57ac099b01fe49dd4e1e4674a06f61029fa6316e4f92a6a2a3bdc0444b371f9", - "zh:cb48a175ebb2a12fecae7dc6580bf88fbcf5408cdc53f3cf057150ebe9144034", + "zh:b57de6903ef30c9f22d38d595d64b4f92a89ea717b65782e1f44f57020ce8b1f", ] } diff --git a/examples/efs/.terraform.lock.hcl b/examples/efs/.terraform.lock.hcl index 63304ce..4459bb1 100644 --- a/examples/efs/.terraform.lock.hcl +++ b/examples/efs/.terraform.lock.hcl @@ -2,21 +2,21 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/hashicorp/aws" { - version = "4.5.0" + version = "4.37.0" constraints = ">= 4.5.0" hashes = [ - "h1:6y12cTFaxpFv4qyU3gkV9M15eSBBrgInoKY1iaHuhvg=", - "zh:0573de96ba316d808be9f8d6fc8e8e68e0e6b614ed4d707bd236c4f7b46ac8b1", - "zh:37560469042f5f43fdb961eb6e6b0a8f95057df68af2c1168d5b8c66ddcb1512", - "zh:44bb4f6bc1f58e19b8bf7041f981a2549a351762d17dd39654eb24d1fa7991c7", - "zh:53af6557b68e547ac5c02cfd0e47ef63c8e9edfacf46921ccc97d73c0cd362c9", - "zh:578a583f69a8e5947d66b2b9d6969690043b6887f6b574263be7ef05f82a82ad", - "zh:6c2d42f30db198a4e7badd7f8037ef9bd951cfd6cf40328c6a7eed96801a374e", - "zh:758f3fc4d833dbdda57a4db743cbbddc8fd8c0492df47771b848447ba7876ce5", - "zh:78241bd45e2f6102055787b3697849fee7e9c28a744ba59cad956639c1aca07b", + "h1:fLTymOb7xIdMkjQU1VDzPA5s+d2vNLZ2shpcFPF7KaY=", + "zh:12c2eb60cb1eb0a41d1afbca6fc6f0eed6ca31a12c51858f951a9e71651afbe0", + "zh:1e17482217c39a12e930e71fd2c9af8af577bec6736b184674476ebcaad28477", + "zh:1e8163c3d871bbd54c189bf2fe5e60e556d67fa399e4c88c8e6ee0834525dc33", + "zh:399c41a3e096fd75d487b98b1791f7cea5bd38567ac4e621c930cb67ec45977c", + "zh:40d4329eef2cc130e4cbed7a6345cb053dd258bf6f5f8eb0f8ce777ae42d5a01", + "zh:625db5fa75638d543b418be7d8046c4b76dc753d9d2184daa0faaaaebc02d207", + "zh:7785c8259f12b45d19fa5abdac6268f3b749fe5a35c8be762c27b7a634a4952b", + "zh:8a7611f33cc6422799c217ec2eeb79c779035ef05331d12505a6002bc48582f0", + "zh:9188178235a73c829872d2e82d88ac6d334d8bb01433e9be31615f1c1633e921", + "zh:994895b57bf225232a5fa7422e6ab87d8163a2f0605f54ff6a18cdd71f0aeadf", "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:a3a7f4699c097c7b8364d05a5df9f3bd5d005fd5736c28ec5dc8f8c0ee340512", - "zh:bf875483bf2ad6cfb4029813328cdcd9ea40f50b9f1c265f4e742fe8cc456157", - "zh:f4722596e8b5f012013f87bf4d2b7d302c248a04a144de4563b3e3f754a30c51", + "zh:b57de6903ef30c9f22d38d595d64b4f92a89ea717b65782e1f44f57020ce8b1f", ] } diff --git a/examples/image/.terraform.lock.hcl b/examples/image/.terraform.lock.hcl index 63304ce..4459bb1 100644 --- a/examples/image/.terraform.lock.hcl +++ b/examples/image/.terraform.lock.hcl @@ -2,21 +2,21 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/hashicorp/aws" { - version = "4.5.0" + version = "4.37.0" constraints = ">= 4.5.0" hashes = [ - "h1:6y12cTFaxpFv4qyU3gkV9M15eSBBrgInoKY1iaHuhvg=", - "zh:0573de96ba316d808be9f8d6fc8e8e68e0e6b614ed4d707bd236c4f7b46ac8b1", - "zh:37560469042f5f43fdb961eb6e6b0a8f95057df68af2c1168d5b8c66ddcb1512", - "zh:44bb4f6bc1f58e19b8bf7041f981a2549a351762d17dd39654eb24d1fa7991c7", - "zh:53af6557b68e547ac5c02cfd0e47ef63c8e9edfacf46921ccc97d73c0cd362c9", - "zh:578a583f69a8e5947d66b2b9d6969690043b6887f6b574263be7ef05f82a82ad", - "zh:6c2d42f30db198a4e7badd7f8037ef9bd951cfd6cf40328c6a7eed96801a374e", - "zh:758f3fc4d833dbdda57a4db743cbbddc8fd8c0492df47771b848447ba7876ce5", - "zh:78241bd45e2f6102055787b3697849fee7e9c28a744ba59cad956639c1aca07b", + "h1:fLTymOb7xIdMkjQU1VDzPA5s+d2vNLZ2shpcFPF7KaY=", + "zh:12c2eb60cb1eb0a41d1afbca6fc6f0eed6ca31a12c51858f951a9e71651afbe0", + "zh:1e17482217c39a12e930e71fd2c9af8af577bec6736b184674476ebcaad28477", + "zh:1e8163c3d871bbd54c189bf2fe5e60e556d67fa399e4c88c8e6ee0834525dc33", + "zh:399c41a3e096fd75d487b98b1791f7cea5bd38567ac4e621c930cb67ec45977c", + "zh:40d4329eef2cc130e4cbed7a6345cb053dd258bf6f5f8eb0f8ce777ae42d5a01", + "zh:625db5fa75638d543b418be7d8046c4b76dc753d9d2184daa0faaaaebc02d207", + "zh:7785c8259f12b45d19fa5abdac6268f3b749fe5a35c8be762c27b7a634a4952b", + "zh:8a7611f33cc6422799c217ec2eeb79c779035ef05331d12505a6002bc48582f0", + "zh:9188178235a73c829872d2e82d88ac6d334d8bb01433e9be31615f1c1633e921", + "zh:994895b57bf225232a5fa7422e6ab87d8163a2f0605f54ff6a18cdd71f0aeadf", "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:a3a7f4699c097c7b8364d05a5df9f3bd5d005fd5736c28ec5dc8f8c0ee340512", - "zh:bf875483bf2ad6cfb4029813328cdcd9ea40f50b9f1c265f4e742fe8cc456157", - "zh:f4722596e8b5f012013f87bf4d2b7d302c248a04a144de4563b3e3f754a30c51", + "zh:b57de6903ef30c9f22d38d595d64b4f92a89ea717b65782e1f44f57020ce8b1f", ] } diff --git a/examples/nlb/.terraform.lock.hcl b/examples/nlb/.terraform.lock.hcl index 63304ce..4459bb1 100644 --- a/examples/nlb/.terraform.lock.hcl +++ b/examples/nlb/.terraform.lock.hcl @@ -2,21 +2,21 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/hashicorp/aws" { - version = "4.5.0" + version = "4.37.0" constraints = ">= 4.5.0" hashes = [ - "h1:6y12cTFaxpFv4qyU3gkV9M15eSBBrgInoKY1iaHuhvg=", - "zh:0573de96ba316d808be9f8d6fc8e8e68e0e6b614ed4d707bd236c4f7b46ac8b1", - "zh:37560469042f5f43fdb961eb6e6b0a8f95057df68af2c1168d5b8c66ddcb1512", - "zh:44bb4f6bc1f58e19b8bf7041f981a2549a351762d17dd39654eb24d1fa7991c7", - "zh:53af6557b68e547ac5c02cfd0e47ef63c8e9edfacf46921ccc97d73c0cd362c9", - "zh:578a583f69a8e5947d66b2b9d6969690043b6887f6b574263be7ef05f82a82ad", - "zh:6c2d42f30db198a4e7badd7f8037ef9bd951cfd6cf40328c6a7eed96801a374e", - "zh:758f3fc4d833dbdda57a4db743cbbddc8fd8c0492df47771b848447ba7876ce5", - "zh:78241bd45e2f6102055787b3697849fee7e9c28a744ba59cad956639c1aca07b", + "h1:fLTymOb7xIdMkjQU1VDzPA5s+d2vNLZ2shpcFPF7KaY=", + "zh:12c2eb60cb1eb0a41d1afbca6fc6f0eed6ca31a12c51858f951a9e71651afbe0", + "zh:1e17482217c39a12e930e71fd2c9af8af577bec6736b184674476ebcaad28477", + "zh:1e8163c3d871bbd54c189bf2fe5e60e556d67fa399e4c88c8e6ee0834525dc33", + "zh:399c41a3e096fd75d487b98b1791f7cea5bd38567ac4e621c930cb67ec45977c", + "zh:40d4329eef2cc130e4cbed7a6345cb053dd258bf6f5f8eb0f8ce777ae42d5a01", + "zh:625db5fa75638d543b418be7d8046c4b76dc753d9d2184daa0faaaaebc02d207", + "zh:7785c8259f12b45d19fa5abdac6268f3b749fe5a35c8be762c27b7a634a4952b", + "zh:8a7611f33cc6422799c217ec2eeb79c779035ef05331d12505a6002bc48582f0", + "zh:9188178235a73c829872d2e82d88ac6d334d8bb01433e9be31615f1c1633e921", + "zh:994895b57bf225232a5fa7422e6ab87d8163a2f0605f54ff6a18cdd71f0aeadf", "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:a3a7f4699c097c7b8364d05a5df9f3bd5d005fd5736c28ec5dc8f8c0ee340512", - "zh:bf875483bf2ad6cfb4029813328cdcd9ea40f50b9f1c265f4e742fe8cc456157", - "zh:f4722596e8b5f012013f87bf4d2b7d302c248a04a144de4563b3e3f754a30c51", + "zh:b57de6903ef30c9f22d38d595d64b4f92a89ea717b65782e1f44f57020ce8b1f", ] } diff --git a/examples/no-lb/.terraform.lock.hcl b/examples/no-lb/.terraform.lock.hcl index 63304ce..4459bb1 100644 --- a/examples/no-lb/.terraform.lock.hcl +++ b/examples/no-lb/.terraform.lock.hcl @@ -2,21 +2,21 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/hashicorp/aws" { - version = "4.5.0" + version = "4.37.0" constraints = ">= 4.5.0" hashes = [ - "h1:6y12cTFaxpFv4qyU3gkV9M15eSBBrgInoKY1iaHuhvg=", - "zh:0573de96ba316d808be9f8d6fc8e8e68e0e6b614ed4d707bd236c4f7b46ac8b1", - "zh:37560469042f5f43fdb961eb6e6b0a8f95057df68af2c1168d5b8c66ddcb1512", - "zh:44bb4f6bc1f58e19b8bf7041f981a2549a351762d17dd39654eb24d1fa7991c7", - "zh:53af6557b68e547ac5c02cfd0e47ef63c8e9edfacf46921ccc97d73c0cd362c9", - "zh:578a583f69a8e5947d66b2b9d6969690043b6887f6b574263be7ef05f82a82ad", - "zh:6c2d42f30db198a4e7badd7f8037ef9bd951cfd6cf40328c6a7eed96801a374e", - "zh:758f3fc4d833dbdda57a4db743cbbddc8fd8c0492df47771b848447ba7876ce5", - "zh:78241bd45e2f6102055787b3697849fee7e9c28a744ba59cad956639c1aca07b", + "h1:fLTymOb7xIdMkjQU1VDzPA5s+d2vNLZ2shpcFPF7KaY=", + "zh:12c2eb60cb1eb0a41d1afbca6fc6f0eed6ca31a12c51858f951a9e71651afbe0", + "zh:1e17482217c39a12e930e71fd2c9af8af577bec6736b184674476ebcaad28477", + "zh:1e8163c3d871bbd54c189bf2fe5e60e556d67fa399e4c88c8e6ee0834525dc33", + "zh:399c41a3e096fd75d487b98b1791f7cea5bd38567ac4e621c930cb67ec45977c", + "zh:40d4329eef2cc130e4cbed7a6345cb053dd258bf6f5f8eb0f8ce777ae42d5a01", + "zh:625db5fa75638d543b418be7d8046c4b76dc753d9d2184daa0faaaaebc02d207", + "zh:7785c8259f12b45d19fa5abdac6268f3b749fe5a35c8be762c27b7a634a4952b", + "zh:8a7611f33cc6422799c217ec2eeb79c779035ef05331d12505a6002bc48582f0", + "zh:9188178235a73c829872d2e82d88ac6d334d8bb01433e9be31615f1c1633e921", + "zh:994895b57bf225232a5fa7422e6ab87d8163a2f0605f54ff6a18cdd71f0aeadf", "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:a3a7f4699c097c7b8364d05a5df9f3bd5d005fd5736c28ec5dc8f8c0ee340512", - "zh:bf875483bf2ad6cfb4029813328cdcd9ea40f50b9f1c265f4e742fe8cc456157", - "zh:f4722596e8b5f012013f87bf4d2b7d302c248a04a144de4563b3e3f754a30c51", + "zh:b57de6903ef30c9f22d38d595d64b4f92a89ea717b65782e1f44f57020ce8b1f", ] } diff --git a/examples/private/.terraform.lock.hcl b/examples/private/.terraform.lock.hcl index 63304ce..4459bb1 100644 --- a/examples/private/.terraform.lock.hcl +++ b/examples/private/.terraform.lock.hcl @@ -2,21 +2,21 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/hashicorp/aws" { - version = "4.5.0" + version = "4.37.0" constraints = ">= 4.5.0" hashes = [ - "h1:6y12cTFaxpFv4qyU3gkV9M15eSBBrgInoKY1iaHuhvg=", - "zh:0573de96ba316d808be9f8d6fc8e8e68e0e6b614ed4d707bd236c4f7b46ac8b1", - "zh:37560469042f5f43fdb961eb6e6b0a8f95057df68af2c1168d5b8c66ddcb1512", - "zh:44bb4f6bc1f58e19b8bf7041f981a2549a351762d17dd39654eb24d1fa7991c7", - "zh:53af6557b68e547ac5c02cfd0e47ef63c8e9edfacf46921ccc97d73c0cd362c9", - "zh:578a583f69a8e5947d66b2b9d6969690043b6887f6b574263be7ef05f82a82ad", - "zh:6c2d42f30db198a4e7badd7f8037ef9bd951cfd6cf40328c6a7eed96801a374e", - "zh:758f3fc4d833dbdda57a4db743cbbddc8fd8c0492df47771b848447ba7876ce5", - "zh:78241bd45e2f6102055787b3697849fee7e9c28a744ba59cad956639c1aca07b", + "h1:fLTymOb7xIdMkjQU1VDzPA5s+d2vNLZ2shpcFPF7KaY=", + "zh:12c2eb60cb1eb0a41d1afbca6fc6f0eed6ca31a12c51858f951a9e71651afbe0", + "zh:1e17482217c39a12e930e71fd2c9af8af577bec6736b184674476ebcaad28477", + "zh:1e8163c3d871bbd54c189bf2fe5e60e556d67fa399e4c88c8e6ee0834525dc33", + "zh:399c41a3e096fd75d487b98b1791f7cea5bd38567ac4e621c930cb67ec45977c", + "zh:40d4329eef2cc130e4cbed7a6345cb053dd258bf6f5f8eb0f8ce777ae42d5a01", + "zh:625db5fa75638d543b418be7d8046c4b76dc753d9d2184daa0faaaaebc02d207", + "zh:7785c8259f12b45d19fa5abdac6268f3b749fe5a35c8be762c27b7a634a4952b", + "zh:8a7611f33cc6422799c217ec2eeb79c779035ef05331d12505a6002bc48582f0", + "zh:9188178235a73c829872d2e82d88ac6d334d8bb01433e9be31615f1c1633e921", + "zh:994895b57bf225232a5fa7422e6ab87d8163a2f0605f54ff6a18cdd71f0aeadf", "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:a3a7f4699c097c7b8364d05a5df9f3bd5d005fd5736c28ec5dc8f8c0ee340512", - "zh:bf875483bf2ad6cfb4029813328cdcd9ea40f50b9f1c265f4e742fe8cc456157", - "zh:f4722596e8b5f012013f87bf4d2b7d302c248a04a144de4563b3e3f754a30c51", + "zh:b57de6903ef30c9f22d38d595d64b4f92a89ea717b65782e1f44f57020ce8b1f", ] } diff --git a/examples/sgs/.terraform.lock.hcl b/examples/sgs/.terraform.lock.hcl index 63304ce..4459bb1 100644 --- a/examples/sgs/.terraform.lock.hcl +++ b/examples/sgs/.terraform.lock.hcl @@ -2,21 +2,21 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/hashicorp/aws" { - version = "4.5.0" + version = "4.37.0" constraints = ">= 4.5.0" hashes = [ - "h1:6y12cTFaxpFv4qyU3gkV9M15eSBBrgInoKY1iaHuhvg=", - "zh:0573de96ba316d808be9f8d6fc8e8e68e0e6b614ed4d707bd236c4f7b46ac8b1", - "zh:37560469042f5f43fdb961eb6e6b0a8f95057df68af2c1168d5b8c66ddcb1512", - "zh:44bb4f6bc1f58e19b8bf7041f981a2549a351762d17dd39654eb24d1fa7991c7", - "zh:53af6557b68e547ac5c02cfd0e47ef63c8e9edfacf46921ccc97d73c0cd362c9", - "zh:578a583f69a8e5947d66b2b9d6969690043b6887f6b574263be7ef05f82a82ad", - "zh:6c2d42f30db198a4e7badd7f8037ef9bd951cfd6cf40328c6a7eed96801a374e", - "zh:758f3fc4d833dbdda57a4db743cbbddc8fd8c0492df47771b848447ba7876ce5", - "zh:78241bd45e2f6102055787b3697849fee7e9c28a744ba59cad956639c1aca07b", + "h1:fLTymOb7xIdMkjQU1VDzPA5s+d2vNLZ2shpcFPF7KaY=", + "zh:12c2eb60cb1eb0a41d1afbca6fc6f0eed6ca31a12c51858f951a9e71651afbe0", + "zh:1e17482217c39a12e930e71fd2c9af8af577bec6736b184674476ebcaad28477", + "zh:1e8163c3d871bbd54c189bf2fe5e60e556d67fa399e4c88c8e6ee0834525dc33", + "zh:399c41a3e096fd75d487b98b1791f7cea5bd38567ac4e621c930cb67ec45977c", + "zh:40d4329eef2cc130e4cbed7a6345cb053dd258bf6f5f8eb0f8ce777ae42d5a01", + "zh:625db5fa75638d543b418be7d8046c4b76dc753d9d2184daa0faaaaebc02d207", + "zh:7785c8259f12b45d19fa5abdac6268f3b749fe5a35c8be762c27b7a634a4952b", + "zh:8a7611f33cc6422799c217ec2eeb79c779035ef05331d12505a6002bc48582f0", + "zh:9188178235a73c829872d2e82d88ac6d334d8bb01433e9be31615f1c1633e921", + "zh:994895b57bf225232a5fa7422e6ab87d8163a2f0605f54ff6a18cdd71f0aeadf", "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:a3a7f4699c097c7b8364d05a5df9f3bd5d005fd5736c28ec5dc8f8c0ee340512", - "zh:bf875483bf2ad6cfb4029813328cdcd9ea40f50b9f1c265f4e742fe8cc456157", - "zh:f4722596e8b5f012013f87bf4d2b7d302c248a04a144de4563b3e3f754a30c51", + "zh:b57de6903ef30c9f22d38d595d64b4f92a89ea717b65782e1f44f57020ce8b1f", ] } diff --git a/optional-task.tf b/optional-task.tf index 383cc8d..5216f4f 100644 --- a/optional-task.tf +++ b/optional-task.tf @@ -121,3 +121,15 @@ variable "entrypoint" { default = null type = list(string) } + +variable "runtime_platform" { + description = "(optional) Runtime platform for the task. Defaults to LINUX operating system family w/ CPU architecture x86_64." + default = { + operating_system_family = "LINUX" + cpu_architecture = "X86_64" + } + type = object({ + operating_system_family = optional(string, "LINUX") + cpu_architecture = optional(string, "X86_64") + }) +} diff --git a/task.tf b/task.tf index bb930f3..a4a2d46 100644 --- a/task.tf +++ b/task.tf @@ -1,6 +1,6 @@ module "task" { count = var.task_def_arn == null ? 1 : 0 - source = "github.com/pbs/terraform-aws-ecs-task-definition-module?ref=0.1.1" + source = "github.com/pbs/terraform-aws-ecs-task-definition-module?ref=0.2.0" name = local.name @@ -41,6 +41,8 @@ module "task" { requires_compatibilities = var.requires_compatibilities container_definitions = var.container_definitions + runtime_platform = var.runtime_platform + organization = var.organization environment = var.environment product = var.product diff --git a/tests/arm_test.go b/tests/arm_test.go new file mode 100644 index 0000000..153b025 --- /dev/null +++ b/tests/arm_test.go @@ -0,0 +1,9 @@ +package test + +import ( + "testing" +) + +func TestARMExample(t *testing.T) { + testECSService(t, "arm") +} diff --git a/tests/utilities_ecs_service.go b/tests/utilities_ecs_service.go index 77f1a3c..eda4211 100644 --- a/tests/utilities_ecs_service.go +++ b/tests/utilities_ecs_service.go @@ -47,7 +47,20 @@ func testECSService(t *testing.T, variant string) { LockTimeout: "5m", } - defer terraform.Destroy(t, terraformOptions) + defer func() { + // To ensure that the service is stopped before stopping the cluster. + terraformTargetServiceOptions := &terraform.Options{ + TerraformDir: terraformDir, + LockTimeout: "5m", + Targets: []string{ + "module.service.aws_ecs_service.service", + "module.service_v1.aws_ecs_service.service", + "module.service_v2.aws_ecs_service.service", + }, + } + terraform.Destroy(t, terraformTargetServiceOptions) + terraform.Destroy(t, terraformOptions) + }() expectedLogGroup := fmt.Sprintf("/ecs/%s", expectedName) @@ -70,7 +83,7 @@ func testECSService(t *testing.T, variant string) { case "sgs": // We need to apply the SGs first because of the count on // user_to_virtual_node_access_sg - terraformTargetEFSOptions := &terraform.Options{ + terraformTargetSGOptions := &terraform.Options{ TerraformDir: terraformDir, LockTimeout: "5m", Targets: []string{ @@ -80,7 +93,7 @@ func testECSService(t *testing.T, variant string) { "aws_security_group.ingress_sg", }, } - terraform.Apply(t, terraformTargetEFSOptions) + terraform.Apply(t, terraformTargetSGOptions) case "am": // We need to apply the virtual gateway first // because of the for_each used on virtual_gateway_ids From f43f42895ca4e5aee0beccbd9bd22bf42af66f47 Mon Sep 17 00:00:00 2001 From: Yousif Akbar <11247449+yhakbar@users.noreply.github.com> Date: Wed, 2 Nov 2022 10:50:10 -0400 Subject: [PATCH 2/4] Empty commit to trigger checks From 3ac3d9ea279afd81cb0771e2d40b6f28e44e7706 Mon Sep 17 00:00:00 2001 From: Yousif Akbar <11247449+yhakbar@users.noreply.github.com> Date: Wed, 2 Nov 2022 11:02:23 -0400 Subject: [PATCH 3/4] Doc update for the addition of ARM support --- README-HEADER.md | 2 ++ README.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README-HEADER.md b/README-HEADER.md index cf43471..4968497 100644 --- a/README-HEADER.md +++ b/README-HEADER.md @@ -20,6 +20,8 @@ To make the service provisioned here private, set `public_service` to `false`. T To switch the kind of load balancer used from an application load balancer to a network load balancer, set `load_balancer_type` to `network`. +To run an ECS service on ARM architecture, set `runtime_platform` accordingly. The `cpu_architecture` object property being set to `ARM64` is what adjusts the task definition such that the tasks run on Graviton hardware for Fargate tasks. + Integrate this module like so: ```hcl diff --git a/README.md b/README.md index 01b3378..2c58f8b 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ To make the service provisioned here private, set `public_service` to `false`. T To switch the kind of load balancer used from an application load balancer to a network load balancer, set `load_balancer_type` to `network`. +To run an ECS service on ARM architecture, set `runtime_platform` accordingly. The `cpu_architecture` object property being set to `ARM64` is what adjusts the task definition such that the tasks run on Graviton hardware for Fargate tasks. + Integrate this module like so: ```hcl From 543173f62f21232cc3e50232b4edcd8e087c2f6e Mon Sep 17 00:00:00 2001 From: Yousif Akbar <11247449+yhakbar@users.noreply.github.com> Date: Wed, 2 Nov 2022 11:13:42 -0400 Subject: [PATCH 4/4] Running document script one more time... hopefully... --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5d2cebe..2c58f8b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ### Using the Repo Source ```hcl -github.com/pbs/terraform-aws-ecs-service-module?ref=2.1.4 +github.com/pbs/terraform-aws-ecs-service-module?ref=x.y.z ``` ### Alternative Installation Methods @@ -26,7 +26,7 @@ Integrate this module like so: ```hcl module "service" { - source = "github.com/pbs/terraform-aws-ecs-service-module?ref=2.1.4" + source = "github.com/pbs/terraform-aws-ecs-service-module?ref=x.y.z" # Required primary_hosted_zone = "example.com" @@ -47,7 +47,7 @@ module "service" { If this repo is added as a subtree, then the version of the module should be close to the version shown here: -`2.1.4` +`x.y.z` Note, however that subtrees can be altered as desired within repositories.
"cpu_architecture": "X86_64",
"operating_system_family": "LINUX"
}