From 0c2e4244c5f3882e5afd5097a0f11d4d8c9785ab Mon Sep 17 00:00:00 2001 From: Abdul Wahid Date: Wed, 26 Jul 2023 13:05:20 +0100 Subject: [PATCH] chore: upgrade to 5.x compatibility + documentation (#17) --- .pre-commit-config.yaml | 10 +++++----- CHANGELOG.md | 9 ++++++++- README.md | 10 +++++----- examples/core/.terraform.lock.hcl | 25 +++++++++++++++++++++++++ examples/core/main.tf | 8 ++------ examples/core/versions.tf | 14 ++++++++++++++ examples/task-efs/main.tf | 4 ---- examples/task-efs/versions.tf | 14 ++++++++++++++ outputs.tf | 30 +++++++++++++++--------------- variables.tf | 2 ++ versions.tf | 8 ++++++-- 11 files changed, 96 insertions(+), 38 deletions(-) create mode 100644 examples/core/.terraform.lock.hcl create mode 100644 examples/core/versions.tf create mode 100644 examples/task-efs/versions.tf diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d2cfb32..645acf5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,13 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.4.0 hooks: - id: check-added-large-files args: ['--maxkb=500'] - id: check-executables-have-shebangs - id: pretty-format-json args: ['--autofix', '--no-sort-keys', '--indent=2'] - - id: check-byte-order-marker + - id: fix-byte-order-marker - id: check-case-conflict - id: check-executables-have-shebangs - id: check-merge-conflict @@ -17,9 +17,9 @@ repos: - id: detect-aws-credentials args: ['--allow-missing-credentials'] - id: trailing-whitespace -- repo: git://github.com/antonbabenko/pre-commit-terraform - rev: v1.50.0 +- repo: https://github.com/antonbabenko/pre-commit-terraform + rev: v1.81.0 hooks: - id: terraform_fmt - id: terraform_docs - - id: terraform_tflint + - id: terraform_tflint \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 86c978a..489bf08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ All notable changes to this project will be documented in this file. + +## [2.1.2] - 2021-07-16 + +- 'task_container_working_directory' encoded with jsonencode function ([#16](https://github.com/umotif-public/terraform-aws-ecs-fargate-task-definition/issues/16)) + + ## [2.1.1] - 2021-04-21 @@ -86,7 +92,8 @@ All notable changes to this project will be documented in this file. - Initial commit -[Unreleased]: https://github.com/umotif-public/terraform-aws-ecs-fargate-task-definition/compare/2.1.1...HEAD +[Unreleased]: https://github.com/umotif-public/terraform-aws-ecs-fargate-task-definition/compare/2.1.2...HEAD +[2.1.2]: https://github.com/umotif-public/terraform-aws-ecs-fargate-task-definition/compare/2.1.1...2.1.2 [2.1.1]: https://github.com/umotif-public/terraform-aws-ecs-fargate-task-definition/compare/2.1.0...2.1.1 [2.1.0]: https://github.com/umotif-public/terraform-aws-ecs-fargate-task-definition/compare/2.0.2...2.1.0 [2.0.2]: https://github.com/umotif-public/terraform-aws-ecs-fargate-task-definition/compare/2.0.1...2.0.2 diff --git a/README.md b/README.md index 71ae96a..454527b 100644 --- a/README.md +++ b/README.md @@ -49,14 +49,14 @@ Module managed by [Marcin Cuber](https://github.com/marcincuber) [LinkedIn](http | Name | Version | |------|---------| -| [terraform](#requirement\_terraform) | >= 0.12.6 | -| [aws](#requirement\_aws) | >= 2.68 | +| [terraform](#requirement\_terraform) | >= 1.0.11 | +| [aws](#requirement\_aws) | >= 3.76.1 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 2.68 | +| [aws](#provider\_aws) | >= 3.76.1 | ## Modules @@ -109,14 +109,14 @@ No modules. | [task\_mount\_points](#input\_task\_mount\_points) | The mount points for data volumes in your container. Each object inside the list requires "sourceVolume", "containerPath" and "readOnly". For more information see https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html | `list(object({ sourceVolume = string, containerPath = string, readOnly = bool }))` | `null` | no | | [task\_start\_timeout](#input\_task\_start\_timeout) | Time duration (in seconds) to wait before giving up on resolving dependencies for a container. If this parameter is not specified, the default value of 3 minutes is used (fargate). | `number` | `null` | no | | [task\_stop\_timeout](#input\_task\_stop\_timeout) | Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own. The max stop timeout value is 120 seconds and if the parameter is not specified, the default value of 30 seconds is used. | `number` | `null` | no | -| [volume](#input\_volume) | (Optional) A set of volume blocks that containers in your task may use. This is a list of maps, where each map should contain "name", "host\_path", "docker\_volume\_configuration" and "efs\_volume\_configuration". Full set of options can be found at https://www.terraform.io/docs/providers/aws/r/ecs_task_definition.html | `list` | `[]` | no | +| [volume](#input\_volume) | (Optional) A set of volume blocks that containers in your task may use. This is a list of maps, where each map should contain "name", "host\_path", "docker\_volume\_configuration" and "efs\_volume\_configuration". Full set of options can be found at https://www.terraform.io/docs/providers/aws/r/ecs_task_definition.html | `any` | `[]` | no | ## Outputs | Name | Description | |------|-------------| | [container\_port](#output\_container\_port) | Port on which the container is listening. | -| [execution\_role\_arn](#output\_execution\_role\_arn) | The Amazon Resource Name (ARN) of execution role. | +| [execution\_role\_arn](#output\_execution\_role\_arn) | The Amazon Resource Name (ARN : null of execution role. | | [execution\_role\_create\_date](#output\_execution\_role\_create\_date) | The creation date of the IAM role. | | [execution\_role\_id](#output\_execution\_role\_id) | The ID of the execution role. | | [execution\_role\_name](#output\_execution\_role\_name) | The name of the execution service role. | diff --git a/examples/core/.terraform.lock.hcl b/examples/core/.terraform.lock.hcl new file mode 100644 index 0000000..939040a --- /dev/null +++ b/examples/core/.terraform.lock.hcl @@ -0,0 +1,25 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "5.9.0" + constraints = ">= 2.68.0, ~> 5.0" + hashes = [ + "h1:TjctPnxYpg1RZaU1dGW8BSvdmf0t0jsNGU1rEmNIXns=", + "zh:032424d4686ce2ff7c5a4a738491635616afbf6e06b3e7e6a754baa031d1265d", + "zh:1e530b4020544ec94e1fe7b1e4296640eb12cf1bf4f79cd6429ff2c4e6fffaf3", + "zh:24d2eee57a4c78039959dd9bb6dff2b75ed0483d44929550c067c3488307dc62", + "zh:3ad6d736722059664e790a358eacf0e0e60973ec44e70142fb503275de2116c1", + "zh:3f34d81acf86c61ddd271e9c4b8215765037463c3fe3c7aea1dc32a509020cfb", + "zh:65a04aa615fc320059a0871702c83b6be10bce2064056096b46faffe768a698e", + "zh:7fb56c3ce1fe77983627e2931e7c7b73152180c4dfb03e793413d0137c85d6b2", + "zh:90c94cb9d7352468bcd5ba21a56099fe087a072b1936d86f47d54c2a012b708a", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:a109c5f01ed48852fe17847fa8a116dfdb81500794a9cf7e5ef92ea6dec20431", + "zh:a27c5396077a36ac2801d4c1c1132201a9225a65bba0e3b3aded9cc18f2c38ff", + "zh:a86ad796ccb0f2cb8f0ca069c774dbf74964edd3282529726816c72e22164b3c", + "zh:bda8afc64091a2a72e0cc38fde937b2163b1b072a5c41310d255901207571afd", + "zh:d22473894cd7e94b7a971793dd07309569f82913a10e4bd6c22e04f362f03bb9", + "zh:f4dbb6d13511290a5274f5b202e6d9997643f86e4c48e8c5e3c204121082851a", + ] +} diff --git a/examples/core/main.tf b/examples/core/main.tf index 1219fc1..abb7afd 100644 --- a/examples/core/main.tf +++ b/examples/core/main.tf @@ -1,7 +1,3 @@ -provider "aws" { - region = "eu-west-1" -} - ##### # Optional Secret creation for task credentials ##### @@ -31,8 +27,8 @@ module "ecs-task-definition" { task_container_port = "80" task_host_port = "80" - task_definition_cpu = "512" - task_definition_memory = "1024" + task_definition_cpu = "256" + task_definition_memory = "512" task_container_environment = { "ENVIRONEMNT" = "Test" diff --git a/examples/core/versions.tf b/examples/core/versions.tf new file mode 100644 index 0000000..c9b55ff --- /dev/null +++ b/examples/core/versions.tf @@ -0,0 +1,14 @@ +provider "aws" { + region = "eu-west-1" +} + +terraform { + required_version = "1.0.11" + + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5" + } + } +} diff --git a/examples/task-efs/main.tf b/examples/task-efs/main.tf index 220446d..3197d53 100644 --- a/examples/task-efs/main.tf +++ b/examples/task-efs/main.tf @@ -1,7 +1,3 @@ -provider "aws" { - region = "eu-west-1" -} - resource "aws_efs_file_system" "efs" { creation_token = "efs-html" diff --git a/examples/task-efs/versions.tf b/examples/task-efs/versions.tf new file mode 100644 index 0000000..c9b55ff --- /dev/null +++ b/examples/task-efs/versions.tf @@ -0,0 +1,14 @@ +provider "aws" { + region = "eu-west-1" +} + +terraform { + required_version = "1.0.11" + + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5" + } + } +} diff --git a/outputs.tf b/outputs.tf index c991f8f..fcb4f74 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,69 +1,69 @@ output "task_role_arn" { description = "The Amazon Resource Name (ARN) specifying the ECS service role." - value = join("", aws_iam_role.task.*.arn) + value = var.enabled ? aws_iam_role.task[0].arn : null } output "task_role_name" { description = "The name of the Fargate task service role." - value = join("", aws_iam_role.task.*.name) + value = var.enabled ? aws_iam_role.task[0].name : null } output "task_role_create_date" { description = "The creation date of the IAM role." - value = join("", aws_iam_role.task.*.create_date) + value = var.enabled ? aws_iam_role.task[0].create_date : null } output "task_role_id" { description = "The ID of the role." - value = join("", aws_iam_role.task.*.id) + value = var.enabled ? aws_iam_role.task[0].id : null } output "task_role_unique_id" { description = "The stable and unique string identifying the role." - value = join("", aws_iam_role.task.*.unique_id) + value = var.enabled ? aws_iam_role.task[0].unique_id : null } output "execution_role_arn" { - description = "The Amazon Resource Name (ARN) of execution role." - value = join("", aws_iam_role.execution.*.arn) + description = "The Amazon Resource Name (ARN : null of execution role." + value = var.enabled ? aws_iam_role.execution[0].arn : null } output "execution_role_name" { description = "The name of the execution service role." - value = join("", aws_iam_role.execution.*.name) + value = var.enabled ? aws_iam_role.execution[0].name : null } output "execution_role_create_date" { description = "The creation date of the IAM role." - value = join("", aws_iam_role.execution.*.create_date) + value = var.enabled ? aws_iam_role.execution[0].create_date : null } output "execution_role_id" { description = "The ID of the execution role." - value = join("", aws_iam_role.execution.*.id) + value = var.enabled ? aws_iam_role.execution[0].id : null } output "execution_role_unique_id" { description = "The stable and unique string identifying the role." - value = join("", aws_iam_role.execution.*.unique_id) + value = var.enabled ? aws_iam_role.execution[0].unique_id : null } output "task_definition_arn" { description = "Full ARN of the Task Definition (including both family and revision)." - value = join("", aws_ecs_task_definition.task.*.arn) + value = var.enabled ? aws_ecs_task_definition.task[0].arn : null } output "task_definition_family" { description = "The family of the Task Definition." - value = join("", aws_ecs_task_definition.task.*.family) + value = var.enabled ? aws_ecs_task_definition.task[0].family : null } output "task_definition_revision" { description = "The revision of the task in a particular family." - value = join("", aws_ecs_task_definition.task.*.revision) + value = var.enabled ? aws_ecs_task_definition.task[0].revision : null } output "container_port" { description = "Port on which the container is listening." - value = var.task_container_port + value = var.enabled ? var.task_container_port : null } diff --git a/variables.tf b/variables.tf index 65761ad..728599f 100644 --- a/variables.tf +++ b/variables.tf @@ -114,6 +114,7 @@ variable "repository_credentials_kms_key" { variable "create_repository_credentials_iam_policy" { default = false description = "Set to true if you are specifying `repository_credentials` variable, it will attach IAM policy with necessary permissions to task role." + type = bool } variable "placement_constraints" { @@ -131,6 +132,7 @@ variable "proxy_configuration" { variable "volume" { description = "(Optional) A set of volume blocks that containers in your task may use. This is a list of maps, where each map should contain \"name\", \"host_path\", \"docker_volume_configuration\" and \"efs_volume_configuration\". Full set of options can be found at https://www.terraform.io/docs/providers/aws/r/ecs_task_definition.html" default = [] + type = any } variable "task_health_check" { diff --git a/versions.tf b/versions.tf index f808d07..6492230 100644 --- a/versions.tf +++ b/versions.tf @@ -1,7 +1,11 @@ terraform { - required_version = ">= 0.12.6" + required_version = ">= 1.0.11" required_providers { - aws = ">= 2.68" + aws = { + source = "hashicorp/aws" + version = ">= 3.76.1" + } + } }