grem11n / terraform-aws-vpc-peering

Terraform module to setup VPC peering connection
https://registry.terraform.io/modules/grem11n/vpc-peering/aws/latest
Apache License 2.0
126 stars 91 forks source link

[BUG] Error: Invalid count argument #83

Closed djkerya closed 2 years ago

djkerya commented 2 years ago

Error: Invalid count argument │ │ on .terraform/modules/vpc-peering/main.tf line 59, in resource "aws_route" "this_routes": │ 59: count = var.from_this ? length(local.this_routes) : 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.

djkerya commented 2 years ago

Error: Invalid count argument │ │ on .terraform/modules/vpc-peering/main.tf line 71, in resource "aws_route" "peer_routes": │ 71: count = var.from_peer ? length(local.peer_routes) : 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.

grem11n commented 2 years ago

Hello @djkerya ,

This problem may appear when this module is dependant on some other module. For example, when you're using a module to create VPCs and then this module to peer them together in one Terraform run. The cause it that Terraform the data sources of this module cannot fetch required references, since those resources are not yet created. Notice, that the data sources are calculated as the first step of anu plan/apply operation.

Here is an example of how to use this module with the depends_on directive. Notice, that you have to explicitly provide references of the route tables in this case.

Hope, this helps!

grem11n commented 2 years ago

Closing this issue due to no activity.

djkerya commented 2 years ago

It is just hilarious to close the issue independently it is solved or not.

сб, 26 мар. 2022 г., 16:21 Yurii Rochniak @.***>:

Closed #83 https://github.com/grem11n/terraform-aws-vpc-peering/issues/83.

— Reply to this email directly, view it on GitHub https://github.com/grem11n/terraform-aws-vpc-peering/issues/83#event-6311875931, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDGNZZI2OY77AIY5CN4TGDVB4MOLANCNFSM5OCLD7MQ . You are receiving this because you were mentioned.Message ID: @.*** com>