Skip to content

Commit

Permalink
fix: Converting type of default_capacity_provider_strategy from map…
Browse files Browse the repository at this point in the history
… to list (#28)
  • Loading branch information
sumit-sampang-rai committed Jan 26, 2021
1 parent d7e95b6 commit 44670f5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
terraform.tfstate
*.tfstate*
terraform.tfvars
.terraform.lock.hcl
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 |

Expand Down
4 changes: 2 additions & 2 deletions examples/complete-ecs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/complete-ecs/service-hello-world/versions.tf
Original file line number Diff line number Diff line change
@@ -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"
}
}
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 44670f5

Please sign in to comment.