Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error: Invalid count argument #83

Closed
djkerya opened this issue Feb 10, 2022 · 4 comments
Closed

[BUG] Error: Invalid count argument #83

djkerya opened this issue Feb 10, 2022 · 4 comments
Assignees
Labels

Comments

@djkerya
Copy link

djkerya commented Feb 10, 2022

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
Copy link
Author

djkerya commented Feb 10, 2022

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
Copy link
Owner

grem11n commented Feb 15, 2022

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
Copy link
Owner

grem11n commented Mar 26, 2022

Closing this issue due to no activity.

@grem11n grem11n closed this as completed Mar 26, 2022
@djkerya
Copy link
Author

djkerya commented Mar 27, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants