hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.42k stars 9.51k forks source link

Same statefile produces semi-random failures during initial plan #35557

Closed quentin9696 closed 1 month ago

quentin9696 commented 1 month ago

Terraform Version

Terraform v1.9.4
on linux_amd64
+ provider registry.terraform.io/datadrivers/nexus v2.3.0
+ provider registry.terraform.io/drfaust92/bitbucket v2.42.0
+ provider registry.terraform.io/hashicorp/archive v2.4.2
+ provider registry.terraform.io/hashicorp/aws v5.59.0
+ provider registry.terraform.io/hashicorp/external v2.3.3
+ provider registry.terraform.io/hashicorp/local v2.5.1
+ provider registry.terraform.io/hashicorp/null v3.2.2
+ provider registry.terraform.io/hashicorp/random v3.6.2
+ provider registry.terraform.io/hashicorp/template v2.2.0
+ provider registry.terraform.io/hashicorp/tls v4.0.5
+ provider registry.terraform.io/poseidon/ct v0.13.0

Terraform Configuration Files

Same as #35503

Debug Output

Same as #35503

Expected Behavior

No issues

Actual Behavior

Error looks like this, but resource can be different depending the run │ Error: Invalid index │ │ on .terraform/modules/baseline/route53.tf line 87, in locals: │ 87: route53_dns_customer_facing_zone_id = var.testing_enabled ? data.aws_route53_zone.testing["0"].zone_id : var.route53_create_parent_zone ? module.dns_parent_zone["0"].public_zone_ids[local.parent_domain_name] : module.dns_child_env_zone["0"].public_zone_ids[local.child_domain_name_key] │ ├──────────────── │ │ module.dns_child_env_zone is object with no attributes │ │ The given key does not identify an element in this collection value.

│ Error: Error in function call │ │ on ../../vpc.tf line 260, in output "nat_aws_eips": │ 260: association_id = element(module.vpc["0"].nat_ids, index) │ ├──────────────── │ │ module.vpc["0"].nat_ids is empty tuple │ │ Call to function "element" failed: cannot use element function with an │ empty list. ╵

Steps to Reproduce

Same as #35503

Additional Context

The state file is not the same, but the TF config don't change between with #3503

References

github-actions[bot] commented 2 weeks ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.