From 11ac14b6b0b437a2d31115bec669361001ac9ef1 Mon Sep 17 00:00:00 2001 From: michaelaw320 Date: Fri, 12 Jan 2024 11:25:00 +0900 Subject: [PATCH 1/4] Expose placement constraints on easy EC2 module --- modules/simple/ec2/README.md | 1 + modules/simple/ec2/main.tf | 2 ++ modules/simple/ec2/variables.tf | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/modules/simple/ec2/README.md b/modules/simple/ec2/README.md index 0ac20f9..3a5ce72 100644 --- a/modules/simple/ec2/README.md +++ b/modules/simple/ec2/README.md @@ -63,6 +63,7 @@ No resources. | [memory](#input\_memory) | Memory for this task | `number` | `null` | no | | [name](#input\_name) | The service name. | `string` | n/a | yes | | [network\_mode](#input\_network\_mode) | Network mode of the container, valid options are none, bridge, awsvpc, and host | `string` | `"bridge"` | no | +| [placement\_constraints](#input\_placement\_constraints) | Placement constraints for Task Definition. List of map. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#placement_constraints) | `list(any)` | `[]` | no | | [propagate\_tags](#input\_propagate\_tags) | Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are `SERVICE` and `TASK_DEFINITION`. | `string` | `null` | no | | [proxy\_configuration](#input\_proxy\_configuration) | The proxy configuration details for the App Mesh proxy. Defined as map argument. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#proxy_configuration) | `any` | `null` | no | | [runtime\_platform](#input\_runtime\_platform) | Runtime platform (operating system and CPU architecture) that containers may use. Defined as map argument. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#runtime_platform) | `any` | `null` | no | diff --git a/modules/simple/ec2/main.tf b/modules/simple/ec2/main.tf index dc13d6b..6ec5413 100644 --- a/modules/simple/ec2/main.tf +++ b/modules/simple/ec2/main.tf @@ -45,6 +45,8 @@ module "ec2" { } ] + placement_constraints = var.placement_constraints + wait_for_steady_state = var.wait_for_steady_state enable_ecs_managed_tags = var.enable_ecs_managed_tags diff --git a/modules/simple/ec2/variables.tf b/modules/simple/ec2/variables.tf index 7e88bdf..a4278c1 100644 --- a/modules/simple/ec2/variables.tf +++ b/modules/simple/ec2/variables.tf @@ -149,6 +149,12 @@ variable "capacity_provider_arn" { type = string } +variable "placement_constraints" { + description = "Placement constraints for Task Definition. List of map. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#placement_constraints)" + default = [] + type = list(any) +} + variable "enable_deployment_circuit_breaker_without_rollback" { description = "Enable Deployment Circuit Breaker without Rollback." default = false From a2846009a2c7c7f1139c8bd4be085418684ae9aa Mon Sep 17 00:00:00 2001 From: michaelaw320 Date: Fri, 12 Jan 2024 11:58:21 +0900 Subject: [PATCH 2/4] Separate service and task placement constraints --- modules/core/service/README.md | 5 +++-- modules/core/service/main.tf | 14 +++++++------- modules/core/service/variables.tf | 10 ++++++++-- modules/simple/ec2/README.md | 3 ++- modules/simple/ec2/main.tf | 3 ++- modules/simple/ec2/variables.tf | 8 +++++++- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/modules/core/service/README.md b/modules/core/service/README.md index 1364791..e114c08 100644 --- a/modules/core/service/README.md +++ b/modules/core/service/README.md @@ -22,7 +22,7 @@ Since this module is the closest to the `resources` form, there are a lot of cus | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules @@ -64,10 +64,10 @@ Since this module is the closest to the `resources` form, there are a lot of cus | [name](#input\_name) | The service name. | `string` | n/a | yes | | [network\_configuration](#input\_network\_configuration) | Map of a network configuration for the service. This parameter is required for task definitions that use the awsvpc network mode to receive their own Elastic Network Interface, and it is not supported for other network modes. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#network_configuration) | `any` | `null` | no | | [ordered\_placement\_strategy](#input\_ordered\_placement\_strategy) | List of map of service level strategy rules that are taken into consideration during task placement. List from top to bottom in order of precedence. Max 5. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#ordered_placement_strategy) | `list(any)` | `[]` | no | -| [placement\_constraints](#input\_placement\_constraints) | List of map of placement constraints for Task Definition. Max 10. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#placement_constraints) | `list(any)` | `[]` | no | | [platform\_version](#input\_platform\_version) | The platform version on which to run your service. Only applicable for `launch_type` set to `FARGATE`. Defaults to `LATEST`. [AWS Docs](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html) | `string` | `null` | no | | [propagate\_tags](#input\_propagate\_tags) | Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are `SERVICE` and `TASK_DEFINITION`. | `string` | `null` | no | | [scheduling\_strategy](#input\_scheduling\_strategy) | The scheduling strategy to use for the service. The valid values are `REPLICA` and `DAEMON`. Fargate Tasks do not support `DAEMON` scheduling strategy. | `string` | `null` | no | +| [service\_placement\_constraints](#input\_service\_placement\_constraints) | List of map of placement constraints for Service. Max 10. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#placement_constraints) | `list(any)` | `[]` | no | | [service\_registry](#input\_service\_registry) | Map of a service discovery registries for the service. Consists of `registry_arn`, `port`(optional), `container_port`(optional), `container_port`(optional). [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#service_registries) | `any` | `null` | no | | [tags](#input\_tags) | Key-value mapping of resource tags | `map(string)` | `{}` | no | | [task\_cpu](#input\_task\_cpu) | Task level CPU units. | `number` | `null` | no | @@ -77,6 +77,7 @@ Since this module is the closest to the `resources` form, there are a lot of cus | [task\_memory](#input\_task\_memory) | Task level Memory units. | `number` | `null` | no | | [task\_network\_mode](#input\_task\_network\_mode) | The network mode for container. | `string` | `"bridge"` | no | | [task\_pid\_mode](#input\_task\_pid\_mode) | The process namespace to use for the containers in the task. The valid values are `host` and `task`. | `string` | `null` | no | +| [task\_placement\_constraints](#input\_task\_placement\_constraints) | Placement constraints for Task Definition. List of map. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#placement_constraints) | `list(any)` | `[]` | no | | [task\_proxy\_configuration](#input\_task\_proxy\_configuration) | The proxy configuration details for the App Mesh proxy. Defined as map argument. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#proxy_configuration) | `any` | `null` | no | | [task\_requires\_compatibilites](#input\_task\_requires\_compatibilites) | A set of launch types required by the task. The valid values are `EC2` and `FARGATE`. | `list(string)` |
[
"EC2"
]
| no | | [task\_runtime\_platform](#input\_task\_runtime\_platform) | Runtime platform (operating system and CPU architecture) that containers may use. Defined as map argument. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#runtime_platform) | `any` | `null` | no | diff --git a/modules/core/service/main.tf b/modules/core/service/main.tf index 7528489..8efa148 100644 --- a/modules/core/service/main.tf +++ b/modules/core/service/main.tf @@ -71,10 +71,10 @@ resource "aws_ecs_service" "main" { } dynamic "placement_constraints" { - for_each = var.placement_constraints + for_each = var.service_placement_constraints content { - type = lookup(placement_constraints.value, "type", null) - expression = lookup(placement_constraints.value, "expression", null) + type = lookup(service_placement_constraints.value, "type", null) + expression = lookup(service_placement_constraints.value, "expression", null) } } @@ -171,10 +171,10 @@ resource "aws_ecs_service" "main_ignore_desired_count_changes" { } dynamic "placement_constraints" { - for_each = var.placement_constraints + for_each = var.service_placement_constraints content { - type = lookup(placement_constraints.value, "type", null) - expression = lookup(placement_constraints.value, "expression", null) + type = lookup(service_placement_constraints.value, "type", null) + expression = lookup(service_placement_constraints.value, "expression", null) } } @@ -205,7 +205,7 @@ module "task" { memory = var.task_memory requires_compatibilites = var.task_requires_compatibilites volume_configurations = var.task_volume_configurations - placement_constraints = var.placement_constraints + placement_constraints = var.task_placement_constraints inference_accelerator = var.task_inference_accelerator proxy_configuration = var.task_proxy_configuration runtime_platform = var.task_runtime_platform diff --git a/modules/core/service/variables.tf b/modules/core/service/variables.tf index db3357f..8120a53 100644 --- a/modules/core/service/variables.tf +++ b/modules/core/service/variables.tf @@ -185,8 +185,14 @@ variable "ordered_placement_strategy" { type = list(any) } -variable "placement_constraints" { - description = "List of map of placement constraints for Task Definition. Max 10. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#placement_constraints)" +variable "service_placement_constraints" { + description = "List of map of placement constraints for Service. Max 10. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#placement_constraints)" + default = [] + type = list(any) +} + +variable "task_placement_constraints" { + description = "Placement constraints for Task Definition. List of map. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#placement_constraints)" default = [] type = list(any) } diff --git a/modules/simple/ec2/README.md b/modules/simple/ec2/README.md index 3a5ce72..92ec49b 100644 --- a/modules/simple/ec2/README.md +++ b/modules/simple/ec2/README.md @@ -63,13 +63,14 @@ No resources. | [memory](#input\_memory) | Memory for this task | `number` | `null` | no | | [name](#input\_name) | The service name. | `string` | n/a | yes | | [network\_mode](#input\_network\_mode) | Network mode of the container, valid options are none, bridge, awsvpc, and host | `string` | `"bridge"` | no | -| [placement\_constraints](#input\_placement\_constraints) | Placement constraints for Task Definition. List of map. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#placement_constraints) | `list(any)` | `[]` | no | | [propagate\_tags](#input\_propagate\_tags) | Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are `SERVICE` and `TASK_DEFINITION`. | `string` | `null` | no | | [proxy\_configuration](#input\_proxy\_configuration) | The proxy configuration details for the App Mesh proxy. Defined as map argument. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#proxy_configuration) | `any` | `null` | no | | [runtime\_platform](#input\_runtime\_platform) | Runtime platform (operating system and CPU architecture) that containers may use. Defined as map argument. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#runtime_platform) | `any` | `null` | no | +| [service\_placement\_constraints](#input\_service\_placement\_constraints) | List of map of placement constraints for Service. Max 10. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#placement_constraints) | `list(any)` | `[]` | no | | [service\_registry](#input\_service\_registry) | Map of a service discovery registries for the service. Consists of `registry_arn`, `port`(optional), `container_port`(optional), `container_port`(optional). [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#service_registries) | `any` | `null` | no | | [tags](#input\_tags) | Key-value mapping of resource tags | `map(string)` | `{}` | no | | [target\_group\_arn](#input\_target\_group\_arn) | ARN of the Application Load Balancer / Network Load Balancer target group | `string` | `null` | no | +| [task\_placement\_constraints](#input\_task\_placement\_constraints) | Placement constraints for Task Definition. List of map. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#placement_constraints) | `list(any)` | `[]` | no | | [volume\_configurations](#input\_volume\_configurations) | Volume Block Arguments for Task Definition. List of map. Note that `docker_volume_configuration` should be specified as map argument instead of block. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#volume) | `list(any)` | `[]` | no | | [wait\_for\_steady\_state](#input\_wait\_for\_steady\_state) | If `true`, Terraform will wait for the service to reach a steady state (like aws ecs wait services-stable) before continuing. | `bool` | `null` | no | diff --git a/modules/simple/ec2/main.tf b/modules/simple/ec2/main.tf index 6ec5413..4ebff0a 100644 --- a/modules/simple/ec2/main.tf +++ b/modules/simple/ec2/main.tf @@ -45,7 +45,8 @@ module "ec2" { } ] - placement_constraints = var.placement_constraints + service_placement_constraints = var.service_placement_constraints + task_placement_constraints = var.task_placement_constraints wait_for_steady_state = var.wait_for_steady_state diff --git a/modules/simple/ec2/variables.tf b/modules/simple/ec2/variables.tf index a4278c1..0f22494 100644 --- a/modules/simple/ec2/variables.tf +++ b/modules/simple/ec2/variables.tf @@ -149,7 +149,13 @@ variable "capacity_provider_arn" { type = string } -variable "placement_constraints" { +variable "service_placement_constraints" { + description = "List of map of placement constraints for Service. Max 10. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#placement_constraints)" + default = [] + type = list(any) +} + +variable "task_placement_constraints" { description = "Placement constraints for Task Definition. List of map. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#placement_constraints)" default = [] type = list(any) From 343f429ecd516bc8ee1f8e41abe3fac1ea8f95ed Mon Sep 17 00:00:00 2001 From: michaelaw320 Date: Fri, 12 Jan 2024 12:58:36 +0900 Subject: [PATCH 3/4] Add convenience flag on easy module to force distinct instance placement --- README.md | 2 +- examples/complete-ecs/README.md | 2 +- examples/easy/ec2-alb/README.md | 2 +- examples/easy/ec2-alb/main.tf | 6 +- examples/easy/ec2-distinct/README.md | 72 ++++++++++++ examples/easy/ec2-distinct/main.tf | 103 ++++++++++++++++++ examples/easy/ec2-distinct/outputs.tf | 0 examples/easy/ec2-distinct/variables.tf | 16 +++ examples/easy/ec2-distinct/versions.tf | 10 ++ examples/easy/ec2/README.md | 2 +- examples/easy/ec2/main.tf | 6 +- examples/easy/fargate-alb/README.md | 2 +- examples/easy/fargate-spot/README.md | 2 +- examples/easy/fargate/README.md | 2 +- .../target-requests-count/README.md | 2 +- .../target-response-time/README.md | 2 +- .../ecs-reservation/README.md | 2 +- modules/autoscaling/ecs-scheduled/README.md | 2 +- .../service-utilization/README.md | 2 +- modules/core/ecs-autoscaling-target/README.md | 2 +- modules/core/service/main.tf | 8 +- modules/core/task/README.md | 2 +- modules/iam/ecs-instance-profile/README.md | 2 +- modules/scheduled-actions/README.md | 2 +- modules/simple/ec2/README.md | 3 +- modules/simple/ec2/main.tf | 3 +- modules/simple/ec2/variables.tf | 14 +-- 27 files changed, 235 insertions(+), 38 deletions(-) create mode 100644 examples/easy/ec2-distinct/README.md create mode 100644 examples/easy/ec2-distinct/main.tf create mode 100644 examples/easy/ec2-distinct/outputs.tf create mode 100644 examples/easy/ec2-distinct/variables.tf create mode 100644 examples/easy/ec2-distinct/versions.tf diff --git a/README.md b/README.md index f644209..52eca63 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ This module uses Semver. | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/examples/complete-ecs/README.md b/examples/complete-ecs/README.md index 1b31d48..bed7514 100644 --- a/examples/complete-ecs/README.md +++ b/examples/complete-ecs/README.md @@ -38,7 +38,7 @@ $ terraform apply | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/examples/easy/ec2-alb/README.md b/examples/easy/ec2-alb/README.md index 5809c4f..17a2b81 100644 --- a/examples/easy/ec2-alb/README.md +++ b/examples/easy/ec2-alb/README.md @@ -31,7 +31,7 @@ To test that it's working: | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/examples/easy/ec2-alb/main.tf b/examples/easy/ec2-alb/main.tf index 1e5535e..6f5d6f3 100644 --- a/examples/easy/ec2-alb/main.tf +++ b/examples/easy/ec2-alb/main.tf @@ -28,6 +28,8 @@ module "vpc" { enable_dhcp_options = true dhcp_options_domain_name_servers = ["AmazonProvidedDNS"] + map_public_ip_on_launch = true + enable_ipv6 = var.enable_ipv6 public_subnet_assign_ipv6_address_on_creation = var.enable_ipv6 public_subnet_ipv6_prefixes = range(length(local.vpc_azs)) @@ -118,9 +120,9 @@ module "asg" { max_size = 2 desired_capacity = 1 health_check_type = "EC2" - user_data = templatefile("../../templates/ec2_userdata.tpl", { + user_data = base64encode(templatefile("../../templates/ec2_userdata.tpl", { ecs_cluster = module.ecs_cluster.name - }) + })) iam_instance_profile_arn = var.instance_profile_arn } diff --git a/examples/easy/ec2-distinct/README.md b/examples/easy/ec2-distinct/README.md new file mode 100644 index 0000000..b749835 --- /dev/null +++ b/examples/easy/ec2-distinct/README.md @@ -0,0 +1,72 @@ +# examples/easy/ec2-distinct + +In this example we'll instantiate a simple nginx webserver running in **3 distinct instances**. + +Task networking mode in this example is `host` so that the port specified in `templates/container_definitions.tpl` will be bind. +Means there cannot be more than 1 task in an instance. Do experiment with dynamic port mapping with `bridge` network mode. + +This example will also create `vpc` and `security_group` and `autoscaling group`. + +Note: Instance profile is required for EC2 to connect to ECS Cluster. See [`modules/iam/ecs-instance-profile`](https://github.com/HENNGE/terraform-aws-ecs/tree/main/modules/iam/ecs-instance-profile). + +To test that it's working: +1. Go to EC2 console +1. Find the EC2 instance started by this example. (Search the name) +1. Go to the IP Address, you should see nginx hello world screen + +## Usage + +To run this example you need to execute: + +```bash +$ terraform init +$ terraform plan +$ terraform apply +``` + + + +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 1.0 | +| [aws](#requirement\_aws) | >= 3.74.0 | + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | 5.32.0 | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [asg](#module\_asg) | terraform-aws-modules/autoscaling/aws | ~> 7.0 | +| [easy\_ec2\_distinct\_instance\_mode](#module\_easy\_ec2\_distinct\_instance\_mode) | ../../../modules/simple/ec2 | n/a | +| [ec2\_security\_group](#module\_ec2\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 | +| [ecs\_cluster](#module\_ecs\_cluster) | ../../.. | n/a | +| [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 | + +## Resources + +| Name | Type | +|------|------| +| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source | +| [aws_ssm_parameter.ami_image](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [availability\_zones](#input\_availability\_zones) | Override automatic detection of availability zones | `list(string)` | `[]` | no | +| [enable\_ipv6](#input\_enable\_ipv6) | Enable IPv6? | `bool` | `true` | no | +| [instance\_profile\_arn](#input\_instance\_profile\_arn) | Instance Profile to use for EC2 to join to ECS Cluster. See `modules/iam/ecs-instance-profile` | `string` | n/a | yes | + +## Outputs + +No outputs. + + + diff --git a/examples/easy/ec2-distinct/main.tf b/examples/easy/ec2-distinct/main.tf new file mode 100644 index 0000000..fd621f0 --- /dev/null +++ b/examples/easy/ec2-distinct/main.tf @@ -0,0 +1,103 @@ +# Just Supporting Infrastructures + +data "aws_availability_zones" "available" {} + +data "aws_ssm_parameter" "ami_image" { + name = "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id" +} + +locals { + prefix = "easy-ec2" + + vpc_cidr = "10.0.0.0/16" + discovered_azs = data.aws_availability_zones.available.names + vpc_azs = length(var.availability_zones) == 0 ? local.discovered_azs : var.availability_zones +} + +module "vpc" { + source = "terraform-aws-modules/vpc/aws" + version = "~> 5.0" + + name = "${local.prefix}-vpc" + cidr = local.vpc_cidr + azs = local.vpc_azs + + public_subnets = [for i in range(length(local.vpc_azs)) : cidrsubnet(local.vpc_cidr, 8, i)] + + enable_nat_gateway = false + enable_dhcp_options = true + dhcp_options_domain_name_servers = ["AmazonProvidedDNS"] + + map_public_ip_on_launch = true + + enable_ipv6 = var.enable_ipv6 + public_subnet_assign_ipv6_address_on_creation = var.enable_ipv6 + public_subnet_ipv6_prefixes = range(length(local.vpc_azs)) +} + +module "ec2_security_group" { + source = "terraform-aws-modules/security-group/aws" + version = "~> 4.0" + + name = "${local.prefix}-ec2-sg" + vpc_id = module.vpc.vpc_id + + + # Ingress for HTTP + ingress_cidr_blocks = ["0.0.0.0/0"] + ingress_ipv6_cidr_blocks = ["::/0"] + ingress_rules = ["http-80-tcp"] + + # Allow all egress + egress_cidr_blocks = ["0.0.0.0/0"] + egress_ipv6_cidr_blocks = ["::/0"] + egress_rules = ["all-all"] +} + +module "asg" { + source = "terraform-aws-modules/autoscaling/aws" + version = "~> 7.0" + + name = "${local.prefix}-asg" + + image_id = data.aws_ssm_parameter.ami_image.value + instance_type = "t2.micro" + security_groups = [module.ec2_security_group.security_group_id] + vpc_zone_identifier = module.vpc.public_subnets + min_size = 1 + max_size = 5 + desired_capacity = 3 + health_check_type = "EC2" + user_data = base64encode(templatefile("../../templates/ec2_userdata.tpl", { + ecs_cluster = module.ecs_cluster.name + })) + iam_instance_profile_arn = var.instance_profile_arn +} + +# This module usage starts here +module "ecs_cluster" { + source = "../../.." + + name = "${local.prefix}-cluster" +} + +module "easy_ec2_distinct_instance_mode" { + source = "../../../modules/simple/ec2" + + name = "${local.prefix}-service" + cluster = module.ecs_cluster.name + cpu = 256 + memory = 512 + desired_count = 3 + ignore_desired_count_changes = false + + network_mode = "host" + + distinct_instance = true + + container_definitions = templatefile("../../templates/container_definitions.tpl", { + name = "${local.prefix}-cont" + cpu = 256 + memory = 512 + }) +} diff --git a/examples/easy/ec2-distinct/outputs.tf b/examples/easy/ec2-distinct/outputs.tf new file mode 100644 index 0000000..e69de29 diff --git a/examples/easy/ec2-distinct/variables.tf b/examples/easy/ec2-distinct/variables.tf new file mode 100644 index 0000000..c549865 --- /dev/null +++ b/examples/easy/ec2-distinct/variables.tf @@ -0,0 +1,16 @@ +variable "instance_profile_arn" { + description = "Instance Profile to use for EC2 to join to ECS Cluster. See `modules/iam/ecs-instance-profile`" + type = string +} + +variable "availability_zones" { + description = "Override automatic detection of availability zones" + default = [] + type = list(string) +} + +variable "enable_ipv6" { + description = "Enable IPv6?" + default = true + type = bool +} diff --git a/examples/easy/ec2-distinct/versions.tf b/examples/easy/ec2-distinct/versions.tf new file mode 100644 index 0000000..88a651b --- /dev/null +++ b/examples/easy/ec2-distinct/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.74.0" + } + } +} diff --git a/examples/easy/ec2/README.md b/examples/easy/ec2/README.md index 8bf3b8a..b3cb000 100644 --- a/examples/easy/ec2/README.md +++ b/examples/easy/ec2/README.md @@ -37,7 +37,7 @@ $ terraform apply | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/examples/easy/ec2/main.tf b/examples/easy/ec2/main.tf index a39e5b6..e26bcb6 100644 --- a/examples/easy/ec2/main.tf +++ b/examples/easy/ec2/main.tf @@ -28,6 +28,8 @@ module "vpc" { enable_dhcp_options = true dhcp_options_domain_name_servers = ["AmazonProvidedDNS"] + map_public_ip_on_launch = true + enable_ipv6 = var.enable_ipv6 public_subnet_assign_ipv6_address_on_creation = var.enable_ipv6 public_subnet_ipv6_prefixes = range(length(local.vpc_azs)) @@ -66,9 +68,9 @@ module "asg" { max_size = 2 desired_capacity = 1 health_check_type = "EC2" - user_data = templatefile("../../templates/ec2_userdata.tpl", { + user_data = base64encode(templatefile("../../templates/ec2_userdata.tpl", { ecs_cluster = module.ecs_cluster.name - }) + })) iam_instance_profile_arn = var.instance_profile_arn } diff --git a/examples/easy/fargate-alb/README.md b/examples/easy/fargate-alb/README.md index 74bc600..72636fa 100644 --- a/examples/easy/fargate-alb/README.md +++ b/examples/easy/fargate-alb/README.md @@ -38,7 +38,7 @@ $ terraform apply | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/examples/easy/fargate-spot/README.md b/examples/easy/fargate-spot/README.md index 8394aaf..c306c55 100644 --- a/examples/easy/fargate-spot/README.md +++ b/examples/easy/fargate-spot/README.md @@ -43,7 +43,7 @@ $ terraform apply | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/examples/easy/fargate/README.md b/examples/easy/fargate/README.md index 171349d..d38e884 100644 --- a/examples/easy/fargate/README.md +++ b/examples/easy/fargate/README.md @@ -36,7 +36,7 @@ $ terraform apply | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/modules/autoscaling/alb-target-tracking/target-requests-count/README.md b/modules/autoscaling/alb-target-tracking/target-requests-count/README.md index c72ce54..4429414 100644 --- a/modules/autoscaling/alb-target-tracking/target-requests-count/README.md +++ b/modules/autoscaling/alb-target-tracking/target-requests-count/README.md @@ -70,7 +70,7 @@ module "ecs_service_scaling" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/modules/autoscaling/alb-target-tracking/target-response-time/README.md b/modules/autoscaling/alb-target-tracking/target-response-time/README.md index 4dbce74..c06a169 100644 --- a/modules/autoscaling/alb-target-tracking/target-response-time/README.md +++ b/modules/autoscaling/alb-target-tracking/target-response-time/README.md @@ -71,7 +71,7 @@ module "ecs_service_scaling" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/modules/autoscaling/asg-target-tracking/ecs-reservation/README.md b/modules/autoscaling/asg-target-tracking/ecs-reservation/README.md index 8473f85..1b7d199 100644 --- a/modules/autoscaling/asg-target-tracking/ecs-reservation/README.md +++ b/modules/autoscaling/asg-target-tracking/ecs-reservation/README.md @@ -85,7 +85,7 @@ module "asg_scaling" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/modules/autoscaling/ecs-scheduled/README.md b/modules/autoscaling/ecs-scheduled/README.md index db57a7a..0aa34ce 100644 --- a/modules/autoscaling/ecs-scheduled/README.md +++ b/modules/autoscaling/ecs-scheduled/README.md @@ -47,7 +47,7 @@ module "ecs_scaling_scheduled" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/modules/autoscaling/ecs-target-tracking/service-utilization/README.md b/modules/autoscaling/ecs-target-tracking/service-utilization/README.md index 5000305..8553e32 100644 --- a/modules/autoscaling/ecs-target-tracking/service-utilization/README.md +++ b/modules/autoscaling/ecs-target-tracking/service-utilization/README.md @@ -62,7 +62,7 @@ module "ecs_service_scaling" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/modules/core/ecs-autoscaling-target/README.md b/modules/core/ecs-autoscaling-target/README.md index e5e41ec..66fbd26 100644 --- a/modules/core/ecs-autoscaling-target/README.md +++ b/modules/core/ecs-autoscaling-target/README.md @@ -61,7 +61,7 @@ module "ecs_service_scaling_target" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/modules/core/service/main.tf b/modules/core/service/main.tf index 8efa148..2cdd7ad 100644 --- a/modules/core/service/main.tf +++ b/modules/core/service/main.tf @@ -73,8 +73,8 @@ resource "aws_ecs_service" "main" { dynamic "placement_constraints" { for_each = var.service_placement_constraints content { - type = lookup(service_placement_constraints.value, "type", null) - expression = lookup(service_placement_constraints.value, "expression", null) + type = lookup(placement_constraints.value, "type", null) + expression = lookup(placement_constraints.value, "expression", null) } } @@ -173,8 +173,8 @@ resource "aws_ecs_service" "main_ignore_desired_count_changes" { dynamic "placement_constraints" { for_each = var.service_placement_constraints content { - type = lookup(service_placement_constraints.value, "type", null) - expression = lookup(service_placement_constraints.value, "expression", null) + type = lookup(placement_constraints.value, "type", null) + expression = lookup(placement_constraints.value, "expression", null) } } diff --git a/modules/core/task/README.md b/modules/core/task/README.md index ff8be56..d31fd8e 100644 --- a/modules/core/task/README.md +++ b/modules/core/task/README.md @@ -18,7 +18,7 @@ Almost a 1-1 mapping to `resources`. | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/modules/iam/ecs-instance-profile/README.md b/modules/iam/ecs-instance-profile/README.md index c22ad5a..9552d7f 100644 --- a/modules/iam/ecs-instance-profile/README.md +++ b/modules/iam/ecs-instance-profile/README.md @@ -16,7 +16,7 @@ Module to generate IAM Instance Profile (and Role) for EC2 instances backing ECS | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/modules/scheduled-actions/README.md b/modules/scheduled-actions/README.md index 05ceefc..49b19be 100644 --- a/modules/scheduled-actions/README.md +++ b/modules/scheduled-actions/README.md @@ -82,7 +82,7 @@ module "ecs_fargate_cron" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.74.0 | +| [aws](#provider\_aws) | 5.32.0 | ## Modules diff --git a/modules/simple/ec2/README.md b/modules/simple/ec2/README.md index 92ec49b..260104d 100644 --- a/modules/simple/ec2/README.md +++ b/modules/simple/ec2/README.md @@ -49,6 +49,7 @@ No resources. | [deployment\_maximum\_percent](#input\_deployment\_maximum\_percent) | upper limit (% of `desired_count`) of # of running tasks during a deployment. Do not fill when using `DAEMON` scheduling strategy. | `number` | `null` | no | | [deployment\_minimum\_healthy\_percent](#input\_deployment\_minimum\_healthy\_percent) | lower limit (% of `desired_count`) of # of running tasks during a deployment | `number` | `100` | no | | [desired\_count](#input\_desired\_count) | The number of instances of the task definition to place and keep running. Defaults to 0. Do not specify if using the `DAEMON` scheduling strategy. | `number` | `null` | no | +| [distinct\_instance](#input\_distinct\_instance) | Make the service run tasks in distinct instance. Sets the service\_placement\_constraints to distinctInstance. | `bool` | `false` | no | | [elb\_name](#input\_elb\_name) | Name of ELB (Classic ELB) to associate with the service | `string` | `null` | no | | [enable\_deployment\_circuit\_breaker\_with\_rollback](#input\_enable\_deployment\_circuit\_breaker\_with\_rollback) | Enable Deployment Circuit Breaker with Rollback. When a service deployment fails, the service is rolled back to the last deployment that completed successfully. | `bool` | `false` | no | | [enable\_deployment\_circuit\_breaker\_without\_rollback](#input\_enable\_deployment\_circuit\_breaker\_without\_rollback) | Enable Deployment Circuit Breaker without Rollback. | `bool` | `false` | no | @@ -66,11 +67,9 @@ No resources. | [propagate\_tags](#input\_propagate\_tags) | Specifies whether to propagate the tags from the task definition or the service to the tasks. The valid values are `SERVICE` and `TASK_DEFINITION`. | `string` | `null` | no | | [proxy\_configuration](#input\_proxy\_configuration) | The proxy configuration details for the App Mesh proxy. Defined as map argument. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#proxy_configuration) | `any` | `null` | no | | [runtime\_platform](#input\_runtime\_platform) | Runtime platform (operating system and CPU architecture) that containers may use. Defined as map argument. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#runtime_platform) | `any` | `null` | no | -| [service\_placement\_constraints](#input\_service\_placement\_constraints) | List of map of placement constraints for Service. Max 10. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#placement_constraints) | `list(any)` | `[]` | no | | [service\_registry](#input\_service\_registry) | Map of a service discovery registries for the service. Consists of `registry_arn`, `port`(optional), `container_port`(optional), `container_port`(optional). [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#service_registries) | `any` | `null` | no | | [tags](#input\_tags) | Key-value mapping of resource tags | `map(string)` | `{}` | no | | [target\_group\_arn](#input\_target\_group\_arn) | ARN of the Application Load Balancer / Network Load Balancer target group | `string` | `null` | no | -| [task\_placement\_constraints](#input\_task\_placement\_constraints) | Placement constraints for Task Definition. List of map. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#placement_constraints) | `list(any)` | `[]` | no | | [volume\_configurations](#input\_volume\_configurations) | Volume Block Arguments for Task Definition. List of map. Note that `docker_volume_configuration` should be specified as map argument instead of block. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#volume) | `list(any)` | `[]` | no | | [wait\_for\_steady\_state](#input\_wait\_for\_steady\_state) | If `true`, Terraform will wait for the service to reach a steady state (like aws ecs wait services-stable) before continuing. | `bool` | `null` | no | diff --git a/modules/simple/ec2/main.tf b/modules/simple/ec2/main.tf index 4ebff0a..46dbc47 100644 --- a/modules/simple/ec2/main.tf +++ b/modules/simple/ec2/main.tf @@ -45,8 +45,7 @@ module "ec2" { } ] - service_placement_constraints = var.service_placement_constraints - task_placement_constraints = var.task_placement_constraints + service_placement_constraints = var.distinct_instance ? [{ type = "distinctInstance" }] : [] wait_for_steady_state = var.wait_for_steady_state diff --git a/modules/simple/ec2/variables.tf b/modules/simple/ec2/variables.tf index 0f22494..7510210 100644 --- a/modules/simple/ec2/variables.tf +++ b/modules/simple/ec2/variables.tf @@ -149,16 +149,10 @@ variable "capacity_provider_arn" { type = string } -variable "service_placement_constraints" { - description = "List of map of placement constraints for Service. Max 10. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_service#placement_constraints)" - default = [] - type = list(any) -} - -variable "task_placement_constraints" { - description = "Placement constraints for Task Definition. List of map. [Terraform Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition#placement_constraints)" - default = [] - type = list(any) +variable "distinct_instance" { + description = "Make the service run tasks in distinct instance. Sets the service_placement_constraints to distinctInstance." + default = false + type = bool } variable "enable_deployment_circuit_breaker_without_rollback" { From f4ed0fa1cc4a7c619b972e7899bbeec8035315d1 Mon Sep 17 00:00:00 2001 From: michaelaw320 Date: Fri, 12 Jan 2024 13:19:34 +0900 Subject: [PATCH 4/4] Fix pre-commit --- .pre-commit-config.yaml | 35 ++++++++++--------- README.md | 2 +- examples/complete-ecs/README.md | 4 +-- examples/easy/ec2-alb/README.md | 4 +-- examples/easy/ec2-distinct/README.md | 4 +-- examples/easy/ec2/README.md | 4 +-- examples/easy/fargate-alb/README.md | 2 +- examples/easy/fargate-spot/README.md | 2 +- examples/easy/fargate/README.md | 2 +- examples/templates/container_definitions.tpl | 2 +- .../container_definitions_ec2_dynamic.tpl | 2 +- .../target-requests-count/README.md | 2 +- .../target-response-time/README.md | 2 +- .../ecs-reservation/README.md | 2 +- modules/autoscaling/ecs-scheduled/README.md | 2 +- .../service-utilization/README.md | 2 +- .../service-utilization/variables.tf | 2 +- modules/core/README.md | 1 - modules/core/ecs-autoscaling-target/README.md | 4 +-- modules/core/service/README.md | 4 +-- modules/core/task/README.md | 4 +-- modules/iam/ecs-instance-profile/README.md | 4 +-- modules/scheduled-actions/README.md | 3 +- modules/simple/ec2/README.md | 2 -- modules/simple/ec2/main.tf | 2 +- modules/simple/fargate-spot/README.md | 2 -- modules/simple/fargate-spot/main.tf | 2 +- modules/simple/fargate/README.md | 2 -- modules/simple/fargate/main.tf | 2 +- 29 files changed, 43 insertions(+), 64 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5489de6..74b0a6b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,26 +1,29 @@ repos: - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.77.2 + rev: v1.86.0 hooks: - id: terraform_fmt - - id: terraform_docs - id: terraform_validate + - id: terraform_docs + args: + - '--args=--lockfile=false' - id: terraform_tflint args: - - "--args=--only=terraform_deprecated_interpolation" - - "--args=--only=terraform_deprecated_index" - - "--args=--only=terraform_unused_declarations" - - "--args=--only=terraform_comment_syntax" - - "--args=--only=terraform_documented_outputs" - - "--args=--only=terraform_documented_variables" - - "--args=--only=terraform_typed_variables" - - "--args=--only=terraform_module_pinned_source" - - "--args=--only=terraform_naming_convention" - - "--args=--only=terraform_required_version" - - "--args=--only=terraform_required_providers" - - "--args=--only=terraform_standard_module_structure" - - "--args=--only=terraform_workspace_remote" + - '--args=--only=terraform_deprecated_interpolation' + - '--args=--only=terraform_deprecated_index' + - '--args=--only=terraform_unused_declarations' + - '--args=--only=terraform_comment_syntax' + - '--args=--only=terraform_documented_outputs' + - '--args=--only=terraform_documented_variables' + - '--args=--only=terraform_typed_variables' + - '--args=--only=terraform_module_pinned_source' + - '--args=--only=terraform_naming_convention' + - '--args=--only=terraform_required_version' + - '--args=--only=terraform_required_providers' + - '--args=--only=terraform_standard_module_structure' + - '--args=--only=terraform_workspace_remote' - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v4.5.0 hooks: - id: check-merge-conflict + - id: end-of-file-fixer diff --git a/README.md b/README.md index 52eca63..f644209 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ This module uses Semver. | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules diff --git a/examples/complete-ecs/README.md b/examples/complete-ecs/README.md index bed7514..bb225e9 100644 --- a/examples/complete-ecs/README.md +++ b/examples/complete-ecs/README.md @@ -38,7 +38,7 @@ $ terraform apply | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules @@ -81,5 +81,3 @@ $ terraform apply |------|-------------| | [load\_balancer\_dns](#output\_load\_balancer\_dns) | Accessible load balancer DNS | - - diff --git a/examples/easy/ec2-alb/README.md b/examples/easy/ec2-alb/README.md index 17a2b81..3891fe5 100644 --- a/examples/easy/ec2-alb/README.md +++ b/examples/easy/ec2-alb/README.md @@ -31,7 +31,7 @@ To test that it's working: | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules @@ -66,5 +66,3 @@ To test that it's working: |------|-------------| | [load\_balancer\_dns](#output\_load\_balancer\_dns) | Accessible load balancer DNS | - - diff --git a/examples/easy/ec2-distinct/README.md b/examples/easy/ec2-distinct/README.md index b749835..22d2500 100644 --- a/examples/easy/ec2-distinct/README.md +++ b/examples/easy/ec2-distinct/README.md @@ -37,7 +37,7 @@ $ terraform apply | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules @@ -68,5 +68,3 @@ $ terraform apply No outputs. - - diff --git a/examples/easy/ec2/README.md b/examples/easy/ec2/README.md index b3cb000..49e8a7b 100644 --- a/examples/easy/ec2/README.md +++ b/examples/easy/ec2/README.md @@ -37,7 +37,7 @@ $ terraform apply | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules @@ -68,5 +68,3 @@ $ terraform apply No outputs. - - diff --git a/examples/easy/fargate-alb/README.md b/examples/easy/fargate-alb/README.md index 72636fa..74bc600 100644 --- a/examples/easy/fargate-alb/README.md +++ b/examples/easy/fargate-alb/README.md @@ -38,7 +38,7 @@ $ terraform apply | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules diff --git a/examples/easy/fargate-spot/README.md b/examples/easy/fargate-spot/README.md index c306c55..8394aaf 100644 --- a/examples/easy/fargate-spot/README.md +++ b/examples/easy/fargate-spot/README.md @@ -43,7 +43,7 @@ $ terraform apply | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules diff --git a/examples/easy/fargate/README.md b/examples/easy/fargate/README.md index d38e884..171349d 100644 --- a/examples/easy/fargate/README.md +++ b/examples/easy/fargate/README.md @@ -36,7 +36,7 @@ $ terraform apply | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules diff --git a/examples/templates/container_definitions.tpl b/examples/templates/container_definitions.tpl index 2b01f40..4e0dfcb 100644 --- a/examples/templates/container_definitions.tpl +++ b/examples/templates/container_definitions.tpl @@ -12,4 +12,4 @@ } ] } -] \ No newline at end of file +] diff --git a/examples/templates/container_definitions_ec2_dynamic.tpl b/examples/templates/container_definitions_ec2_dynamic.tpl index 5b922cd..f574622 100644 --- a/examples/templates/container_definitions_ec2_dynamic.tpl +++ b/examples/templates/container_definitions_ec2_dynamic.tpl @@ -13,4 +13,4 @@ } ] } -] \ No newline at end of file +] diff --git a/modules/autoscaling/alb-target-tracking/target-requests-count/README.md b/modules/autoscaling/alb-target-tracking/target-requests-count/README.md index 4429414..c72ce54 100644 --- a/modules/autoscaling/alb-target-tracking/target-requests-count/README.md +++ b/modules/autoscaling/alb-target-tracking/target-requests-count/README.md @@ -70,7 +70,7 @@ module "ecs_service_scaling" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules diff --git a/modules/autoscaling/alb-target-tracking/target-response-time/README.md b/modules/autoscaling/alb-target-tracking/target-response-time/README.md index c06a169..4dbce74 100644 --- a/modules/autoscaling/alb-target-tracking/target-response-time/README.md +++ b/modules/autoscaling/alb-target-tracking/target-response-time/README.md @@ -71,7 +71,7 @@ module "ecs_service_scaling" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules diff --git a/modules/autoscaling/asg-target-tracking/ecs-reservation/README.md b/modules/autoscaling/asg-target-tracking/ecs-reservation/README.md index 1b7d199..8473f85 100644 --- a/modules/autoscaling/asg-target-tracking/ecs-reservation/README.md +++ b/modules/autoscaling/asg-target-tracking/ecs-reservation/README.md @@ -85,7 +85,7 @@ module "asg_scaling" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules diff --git a/modules/autoscaling/ecs-scheduled/README.md b/modules/autoscaling/ecs-scheduled/README.md index 0aa34ce..db57a7a 100644 --- a/modules/autoscaling/ecs-scheduled/README.md +++ b/modules/autoscaling/ecs-scheduled/README.md @@ -47,7 +47,7 @@ module "ecs_scaling_scheduled" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules diff --git a/modules/autoscaling/ecs-target-tracking/service-utilization/README.md b/modules/autoscaling/ecs-target-tracking/service-utilization/README.md index 8553e32..5000305 100644 --- a/modules/autoscaling/ecs-target-tracking/service-utilization/README.md +++ b/modules/autoscaling/ecs-target-tracking/service-utilization/README.md @@ -62,7 +62,7 @@ module "ecs_service_scaling" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules diff --git a/modules/autoscaling/ecs-target-tracking/service-utilization/variables.tf b/modules/autoscaling/ecs-target-tracking/service-utilization/variables.tf index c2defe8..8ebba5a 100644 --- a/modules/autoscaling/ecs-target-tracking/service-utilization/variables.tf +++ b/modules/autoscaling/ecs-target-tracking/service-utilization/variables.tf @@ -48,4 +48,4 @@ variable "disable_scale_in" { description = "Disable scale-in action, defaults to false" default = false type = bool -} \ No newline at end of file +} diff --git a/modules/core/README.md b/modules/core/README.md index 742b8e0..b770d0a 100644 --- a/modules/core/README.md +++ b/modules/core/README.md @@ -4,4 +4,3 @@ This module contains core module to create `ECS Service` `ECS Task` and `ECS Aut Closest to the original `resources` with the streamlining of input. No more confusion on which should be terraform block or assignment, everything becomes assignments by map or list of maps. - diff --git a/modules/core/ecs-autoscaling-target/README.md b/modules/core/ecs-autoscaling-target/README.md index 66fbd26..4bbe6af 100644 --- a/modules/core/ecs-autoscaling-target/README.md +++ b/modules/core/ecs-autoscaling-target/README.md @@ -61,7 +61,7 @@ module "ecs_service_scaling_target" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules @@ -94,5 +94,3 @@ No modules. | [scalable\_dimension](#output\_scalable\_dimension) | Scalable dimension for autoscaling target. Always ecs:service:DesiredCount. | | [service\_namespace](#output\_service\_namespace) | Service namespace for autoscaling target. Always ecs | - - diff --git a/modules/core/service/README.md b/modules/core/service/README.md index e114c08..56fe7ad 100644 --- a/modules/core/service/README.md +++ b/modules/core/service/README.md @@ -22,7 +22,7 @@ Since this module is the closest to the `resources` form, there are a lot of cus | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules @@ -96,5 +96,3 @@ Since this module is the closest to the `resources` form, there are a lot of cus | [task\_definition\_name](#output\_task\_definition\_name) | The name (family) of created Task Definition. | | [task\_definition\_revision](#output\_task\_definition\_revision) | The revision of the task in a particular family | - - diff --git a/modules/core/task/README.md b/modules/core/task/README.md index d31fd8e..a535937 100644 --- a/modules/core/task/README.md +++ b/modules/core/task/README.md @@ -18,7 +18,7 @@ Almost a 1-1 mapping to `resources`. | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules @@ -60,5 +60,3 @@ No modules. | [name](#output\_name) | The created task definition name | | [revision](#output\_revision) | The revision number of the task definition | - - diff --git a/modules/iam/ecs-instance-profile/README.md b/modules/iam/ecs-instance-profile/README.md index 9552d7f..4eaac5a 100644 --- a/modules/iam/ecs-instance-profile/README.md +++ b/modules/iam/ecs-instance-profile/README.md @@ -16,7 +16,7 @@ Module to generate IAM Instance Profile (and Role) for EC2 instances backing ECS | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules @@ -44,5 +44,3 @@ No modules. |------|-------------| | [iam\_instance\_profile\_id](#output\_iam\_instance\_profile\_id) | Instance Profile id | - - diff --git a/modules/scheduled-actions/README.md b/modules/scheduled-actions/README.md index 49b19be..9c6b834 100644 --- a/modules/scheduled-actions/README.md +++ b/modules/scheduled-actions/README.md @@ -82,7 +82,7 @@ module "ecs_fargate_cron" { | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.32.0 | +| [aws](#provider\_aws) | >= 3.74.0 | ## Modules @@ -156,4 +156,3 @@ The template is as follows: ``` This template is taken from `AWS managed policy`, the policy name is `AmazonEC2ContainerServiceEventsRole` - diff --git a/modules/simple/ec2/README.md b/modules/simple/ec2/README.md index 260104d..4279a43 100644 --- a/modules/simple/ec2/README.md +++ b/modules/simple/ec2/README.md @@ -85,5 +85,3 @@ No resources. | [task\_definition\_name](#output\_task\_definition\_name) | The name (family) of created Task Definition. | | [task\_definition\_revision](#output\_task\_definition\_revision) | The revision of the task in a particular family | - - diff --git a/modules/simple/ec2/main.tf b/modules/simple/ec2/main.tf index 46dbc47..7ab93a7 100644 --- a/modules/simple/ec2/main.tf +++ b/modules/simple/ec2/main.tf @@ -53,4 +53,4 @@ module "ec2" { propagate_tags = var.propagate_tags tags = var.tags -} \ No newline at end of file +} diff --git a/modules/simple/fargate-spot/README.md b/modules/simple/fargate-spot/README.md index 7882593..e678259 100644 --- a/modules/simple/fargate-spot/README.md +++ b/modules/simple/fargate-spot/README.md @@ -91,5 +91,3 @@ No resources. | [task\_definition\_name](#output\_task\_definition\_name) | The name (family) of created Task Definition. | | [task\_definition\_revision](#output\_task\_definition\_revision) | The revision of the task in a particular family | - - diff --git a/modules/simple/fargate-spot/main.tf b/modules/simple/fargate-spot/main.tf index b1bac17..8846991 100644 --- a/modules/simple/fargate-spot/main.tf +++ b/modules/simple/fargate-spot/main.tf @@ -65,4 +65,4 @@ module "fargate" { propagate_tags = var.propagate_tags tags = var.tags -} \ No newline at end of file +} diff --git a/modules/simple/fargate/README.md b/modules/simple/fargate/README.md index bee8115..8fc9bc5 100644 --- a/modules/simple/fargate/README.md +++ b/modules/simple/fargate/README.md @@ -86,5 +86,3 @@ No resources. | [task\_definition\_name](#output\_task\_definition\_name) | The name (family) of created Task Definition. | | [task\_definition\_revision](#output\_task\_definition\_revision) | The revision of the task in a particular family | - - diff --git a/modules/simple/fargate/main.tf b/modules/simple/fargate/main.tf index 3860338..9dff757 100644 --- a/modules/simple/fargate/main.tf +++ b/modules/simple/fargate/main.tf @@ -54,4 +54,4 @@ module "fargate" { wait_for_steady_state = var.wait_for_steady_state tags = var.tags -} \ No newline at end of file +}