cn-terraform / terraform-aws-ecs-fargate

AWS ECS Fargate Terraform Module
https://registry.terraform.io/modules/cn-terraform/ecs-fargate
Apache License 2.0
87 stars 57 forks source link

Count issue when first creating an ecs cluster #11

Closed ChrisLanks closed 4 years ago

ChrisLanks commented 4 years ago

Hey guys, While using this template with nothing special, I am getting this error below (running plan). I believe there is an issue with how the modules are built.

Error: Invalid count argument

  on .terraform/modules/nexus.ecs_fargate.ecs-alb/terraform-aws-ecs-alb-1.0.1/main.tf line 172, in resource "aws_lb_listener" "lb_https_listeners":
 172:   count             = var.enable_https ? length(aws_lb_target_group.lb_https_tgs) : 0

The "count" value depends on resource attributes that cannot be determined
until apply, so Terraform cannot predict how many instances will be created.
To work around this, use the -target argument to first apply only the
resources that the count depends on.

Error: Invalid count argument

  on .terraform/modules/nexus.ecs_fargate.ecs-fargate-service/terraform-aws-ecs-fargate-service-2.0.4/main.tf line 123, in resource "aws_security_group_rule" "ingress_through_https":
 123:   count                    = length(data.aws_lb_target_group.lb_https_target_groups)

The "count" value depends on resource attributes that cannot be determined
until apply, so Terraform cannot predict how many instances will be created.
To work around this, use the -target argument to first apply only the
resources that the count depends on.

Please let me know if you have a way around this. Thanks.

jnonino commented 4 years ago

Hi, thanks for reporting!

Fixed on version 2.0.17

mastercoder8 commented 4 years ago

@jnonino this seems to be happening in 2.0.17 version, can you please help

Error: Invalid count argument

  on .terraform/modules/ecs-fargate.ecs-fargate-service/terraform-aws-ecs-fargate-service-2.0.4/main.tf line 113, in resource "aws_security_group_rule" "ingress_through_http":
 113:   count                    = length(data.aws_lb_target_group.lb_http_target_groups)

The "count" value depends on resource attributes that cannot be determined
until apply, so Terraform cannot predict how many instances will be created.
To work around this, use the -target argument to first apply only the
resources that the count depends on.

Error: Invalid count argument

  on .terraform/modules/ecs-fargate.ecs-fargate-service/terraform-aws-ecs-fargate-service-2.0.4/main.tf line 123, in resource "aws_security_group_rule" "ingress_through_https":
 123:   count                    = length(data.aws_lb_target_group.lb_https_target_groups)

The "count" value depends on resource attributes that cannot be determined
until apply, so Terraform cannot predict how many instances will be created.
To work around this, use the -target argument to first apply only the
resources that the count depends on.

Environment:

terraform 0.13.0 cn-terraform/ecs-alb/aws:1.0.2 cn-terraform/ecs-fargate/aws:2.0.17

Deploying each of the modules independently still throws that error..

advissor commented 3 years ago

@jnonino I also see this on the new cluster I am trying to create Version 2.0.17 Error: Invalid count argument

on .terraform/modules/ecs-fargate-oper.ecs-fargate-service/main.tf line 123, in resource "aws_security_group_rule" "ingress_through_https": 123: count = length(data.aws_lb_target_group.lb_https_target_groups)

The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target argument to first apply only the resources that the count depends on.

When not using https lb_http_ports = [8888 ] lb_https_ports = [ ] lb_enable_http = true lb_enable_https = false