From 40e4a7f96099bcc30925c7fb0bd9b2b507ea3ed1 Mon Sep 17 00:00:00 2001 From: Kevin Tibi <2437140+ktibi@users.noreply.github.com> Date: Tue, 10 May 2022 15:54:40 +0200 Subject: [PATCH] Add ephemeral storage support (#27) --- .pre-commit-config.yaml | 4 ++-- .terraform.lock.hcl | 2 ++ README.md | 1 + examples/multiple-containers/.terraform.lock.hcl | 2 ++ examples/test/.terraform.lock.hcl | 4 +++- main.tf | 6 ++++++ variables.tf | 11 +++++++++++ 7 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a08cc39..c2ac9a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - - repo: git://github.com/antonbabenko/pre-commit-terraform - rev: v1.50.0 + - repo: https://github.com/antonbabenko/pre-commit-terraform + rev: v1.71.0 hooks: - id: terraform_docs - id: terraform_fmt diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl index c502763..79a3aec 100644 --- a/.terraform.lock.hcl +++ b/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "4.0.0" constraints = ">= 4.0.0" hashes = [ + "h1:G0toIzBkhRr/UNRdksvnIyPXnGT9nH0A7gWmu93I1Eg=", "h1:StwpoFw0rXHgAVGV1M/QZaN9OfGx/3+mo1EjjFpbu9w=", "h1:wHydn6CP2wkxUfcq4nRw2NdCc4+rERltXaNZ97U0zAo=", "zh:02937cb37860b022e7d996726e7584ca23904baf7852d266f2dd7891ee088ae4", @@ -26,6 +27,7 @@ provider "registry.terraform.io/hashicorp/local" { constraints = ">= 1.2.0" hashes = [ "h1:/OpJKWupvFd8WJX1mTt8vi01pP7dkA6e//4l4C3TExE=", + "h1:EYZdckuGU3n6APs97nS2LxZm3dDtGqyM4qaIvsmac8o=", "h1:KfieWtVyGWwplSoLIB5usKAUnrIkDQBkWaR5TI+4WYg=", "zh:0f1ec65101fa35050978d483d6e8916664b7556800348456ff3d09454ac1eae2", "zh:36e42ac19f5d68467aacf07e6adcf83c7486f2e5b5f4339e9671f68525fc87ab", diff --git a/README.md b/README.md index 993d78b..64633b8 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ In order to run all checks at any point run the following command: | [entrypoint](#input\_entrypoint) | The entry point that is passed to the container | `list(string)` | `null` | no | | [environment](#input\_environment) | The environment variables to pass to the container. This is a list of maps. map\_environment overrides environment |
list(object({| `[]` | no | | [environment\_files](#input\_environment\_files) | One or more files containing the environment variables to pass to the container. This maps to the --env-file option to docker run. The file must be hosted in Amazon S3. This option is only available to tasks using the EC2 launch type. This is a list of maps |
name = string
value = string
}))
list(object({| `[]` | no | +| [ephemeral\_storage\_size](#input\_ephemeral\_storage\_size) | The number of GBs to provision for ephemeral storage on Fargate tasks. Must be greater than or equal to 21 and less than or equal to 200 | `number` | `0` | no | | [essential](#input\_essential) | Determines whether all other containers in a task are stopped, if this container fails or stops for any reason. Due to how Terraform type casts booleans in json it is required to double quote this value | `bool` | `true` | no | | [extra\_hosts](#input\_extra\_hosts) | A list of hostnames and IP address mappings to append to the /etc/hosts file on the container. This is a list of maps |
value = string
type = string
}))
list(object({| `null` | no | | [firelens\_configuration](#input\_firelens\_configuration) | The FireLens configuration for the container. This is used to specify and configure a log router for container logs. For more details, see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_FirelensConfiguration.html |
ipAddress = string
hostname = string
}))
object({| `null` | no | diff --git a/examples/multiple-containers/.terraform.lock.hcl b/examples/multiple-containers/.terraform.lock.hcl index 23bb696..8b9b96c 100644 --- a/examples/multiple-containers/.terraform.lock.hcl +++ b/examples/multiple-containers/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = ">= 4.0.0" hashes = [ "h1:F9BjbxBhuo1A/rP318IUrkW3TAh29i6UC18qwhzCs6c=", + "h1:S6xGPRL08YEuBdemiYZyIBf/YwM4OCvzVuaiuU6kLjc=", "zh:0a2a7eabfeb7dbb17b7f82aff3fa2ba51e836c15e5be4f5468ea44bd1299b48d", "zh:23409c7205d13d2d68b5528e1c49e0a0455d99bbfec61eb0201142beffaa81f7", "zh:3adad2245d97816f3919778b52c58fb2de130938a3e9081358bfbb72ec478d9a", @@ -25,6 +26,7 @@ provider "registry.terraform.io/hashicorp/local" { version = "2.2.2" constraints = ">= 1.2.0" hashes = [ + "h1:5UYW2wJ320IggrzLt8tLD6MowePqycWtH1b2RInHZkE=", "h1:SjDyZXIUHEQzZe10VjhlhZq2a9kgQB6tmqJcpq2BeWg=", "zh:027e4873c69da214e2fed131666d5de92089732a11d096b68257da54d30b6f9d", "zh:0ba2216e16cfb72538d76a4c4945b4567a76f7edbfef926b1c5a08d7bba2a043", diff --git a/examples/test/.terraform.lock.hcl b/examples/test/.terraform.lock.hcl index e19016d..828173c 100644 --- a/examples/test/.terraform.lock.hcl +++ b/examples/test/.terraform.lock.hcl @@ -3,8 +3,9 @@ provider "registry.terraform.io/hashicorp/aws" { version = "4.0.0" - constraints = ">= 3.74.0" + constraints = ">= 4.0.0" hashes = [ + "h1:G0toIzBkhRr/UNRdksvnIyPXnGT9nH0A7gWmu93I1Eg=", "h1:StwpoFw0rXHgAVGV1M/QZaN9OfGx/3+mo1EjjFpbu9w=", "zh:02937cb37860b022e7d996726e7584ca23904baf7852d266f2dd7891ee088ae4", "zh:259dd5790ec5f4e6814c9584c79834dce3d719e932ce662b21f13434e9441194", @@ -25,6 +26,7 @@ provider "registry.terraform.io/hashicorp/local" { constraints = ">= 1.2.0" hashes = [ "h1:/OpJKWupvFd8WJX1mTt8vi01pP7dkA6e//4l4C3TExE=", + "h1:EYZdckuGU3n6APs97nS2LxZm3dDtGqyM4qaIvsmac8o=", "zh:0f1ec65101fa35050978d483d6e8916664b7556800348456ff3d09454ac1eae2", "zh:36e42ac19f5d68467aacf07e6adcf83c7486f2e5b5f4339e9671f68525fc87ab", "zh:6db9db2a1819e77b1642ec3b5e95042b202aee8151a0256d289f2e141bf3ceb3", diff --git a/main.tf b/main.tf index d00b2c6..8b89bab 100644 --- a/main.tf +++ b/main.tf @@ -102,6 +102,12 @@ resource "aws_ecs_task_definition" "td" { type = lookup(proxy_configuration.value, "type", null) } } + dynamic "ephemeral_storage" { + for_each = var.ephemeral_storage_size == 0 ? [] : [var.ephemeral_storage_size] + content { + size_in_gib = var.ephemeral_storage_size + } + } dynamic "volume" { for_each = var.volumes content { diff --git a/variables.tf b/variables.tf index 7871865..d8777b5 100644 --- a/variables.tf +++ b/variables.tf @@ -366,6 +366,17 @@ variable "proxy_configuration" { default = [] } +variable "ephemeral_storage_size" { + type = number + description = "The number of GBs to provision for ephemeral storage on Fargate tasks. Must be greater than or equal to 21 and less than or equal to 200" + default = 0 + + validation { + condition = var.ephemeral_storage_size == 0 || (var.ephemeral_storage_size >= 21 && var.ephemeral_storage_size <= 200) + error_message = "The ephemeral_storage_size value must be inclusively between 21 and 200." + } +} + variable "volumes" { description = "(Optional) A set of volume blocks that containers in your task may use" type = list(object({
type = string
options = map(string)
})