diff --git a/.gitignore b/.gitignore index 4fa2920..4e38126 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ terraform.tfstate *.tfstate* terraform.tfvars +.terraform.lock.hcl diff --git a/README.md b/README.md index 6f829ee..13c39d5 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,11 @@ module "ecs" { capacity_providers = ["FARGATE", "FARGATE_SPOT"] - default_capacity_provider_strategy = { - capacity_provider = "FARGATE_SPOT" - } + default_capacity_provider_strategy = [ + { + capacity_provider = "FARGATE_SPOT" + } + ] tags = { Environment = "Development" @@ -77,7 +79,7 @@ module "ecs" { | capacity\_providers | List of short names of one or more capacity providers to associate with the cluster. Valid values also include FARGATE and FARGATE\_SPOT. | `list(string)` | `[]` | no | | container\_insights | Controls if ECS Cluster has container insights enabled | `bool` | `false` | no | | create\_ecs | Controls if ECS should be created | `bool` | `true` | no | -| default\_capacity\_provider\_strategy | The capacity provider strategy to use by default for the cluster. Can be one or more. | `map(any)` | `{}` | no | +| default\_capacity\_provider\_strategy | The capacity provider strategy to use by default for the cluster. Can be one or more. | `list(map(any))` | `[]` | no | | name | Name to be used on all the resources as identifier, also the name of the ECS cluster | `string` | `null` | no | | tags | A map of tags to add to ECS Cluster | `map(string)` | `{}` | no | diff --git a/examples/complete-ecs/main.tf b/examples/complete-ecs/main.tf index 9c90dc8..6dde0c5 100644 --- a/examples/complete-ecs/main.tf +++ b/examples/complete-ecs/main.tf @@ -39,9 +39,9 @@ module "ecs" { capacity_providers = ["FARGATE", "FARGATE_SPOT", aws_ecs_capacity_provider.prov1.name] - default_capacity_provider_strategy = { + default_capacity_provider_strategy = [{ capacity_provider = aws_ecs_capacity_provider.prov1.name # "FARGATE_SPOT" - } + }] tags = { Environment = local.environment diff --git a/examples/complete-ecs/service-hello-world/versions.tf b/examples/complete-ecs/service-hello-world/versions.tf index 0e62042..5641dfb 100644 --- a/examples/complete-ecs/service-hello-world/versions.tf +++ b/examples/complete-ecs/service-hello-world/versions.tf @@ -1,7 +1,7 @@ terraform { - required_version = ">= 0.12.6, < 0.14" + required_version = ">= 0.12.6" required_providers { - aws = ">= 2.0, < 4.0" + aws = ">= 2.0" } } diff --git a/main.tf b/main.tf index f1ab4f4..0a707dc 100644 --- a/main.tf +++ b/main.tf @@ -6,7 +6,7 @@ resource "aws_ecs_cluster" "this" { capacity_providers = var.capacity_providers dynamic "default_capacity_provider_strategy" { - for_each = length(keys(var.default_capacity_provider_strategy)) == 0 ? [] : [var.default_capacity_provider_strategy] + for_each = var.default_capacity_provider_strategy iterator = strategy content { diff --git a/variables.tf b/variables.tf index e27133b..3da768d 100644 --- a/variables.tf +++ b/variables.tf @@ -18,8 +18,8 @@ variable "capacity_providers" { variable "default_capacity_provider_strategy" { description = "The capacity provider strategy to use by default for the cluster. Can be one or more." - type = map(any) - default = {} + type = list(map(any)) + default = [] } variable "container_insights" {