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

Circular Dependency #21

Open
1 task done
mravily opened this issue Dec 25, 2024 · 1 comment
Open
1 task done

Circular Dependency #21

mravily opened this issue Dec 25, 2024 · 1 comment

Comments

@mravily
Copy link

mravily commented Dec 25, 2024

Description

Hello,

There seems to be a circular dependency around data.aws_availability_zones.available when using the module, which prevents the creation of resources.

The first time I used the module, I have no problem, after few apply/destroy with the same code, the bug appears.

  • ✋ I have searched the open/closed issues and my issue is not listed.

Versions

  • Module version 1.1.12

  • Terraform version:

terraform version
Terraform v1.5.7
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v5.68.0
+ provider registry.terraform.io/hashicorp/local v2.5.2
+ provider registry.terraform.io/hashicorp/null v3.2.3
+ provider registry.terraform.io/hashicorp/tls v4.0.6

Reproduction Code

Steps to reproduce the behavior:

$ terraform apply
[...]
│ Error: Invalid count argument
│ 
│   on .terraform/modules/red5pro/main.tf line 162, in resource "aws_subnet" "red5pro_subnets":
│  162:   count                   = var.vpc_create ? length(data.aws_availability_zones.available[0].names) : 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.
╵

Expected behavior

Ability to apply all ressource on first apply

Actual behavior

Can't apply without target module.red5pro.data.aws_availability_zones.available

terraform apply -target module.red5pro.data.aws_availability_zones.available

Terminal Output Screenshot(s)

Screenshot 2024-12-25 at 12 35 49

@iolesyk
Copy link
Collaborator

iolesyk commented Jan 7, 2025

Hi,

Typically, this process works without issues, and we haven’t encountered this problem in our tests. However, if you’re still experiencing the issue, you need to use terraform apply -target module.red5pro.data.aws_availability_zones.available
Additionally, consider updating to the latest version of Terraform.

Thank you for your patience and support.

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

No branches or pull requests

2 participants