hashicorp / hashicorp/terraform-plugin-sdk
dynamic clause errors with provided variable
- Dominant language
- Go
- Stars
- 485
- Forks
- 244
- Avg merge
- 19h 57m
- Merged PRs (30d)
- 4
Description
### Terraform Version
```
Terraform v1.0.1
on linux_amd64
+ provider registry.terraform.io/cyrilgdn/postgresql v1.13.0
+ provider registry.terraform.io/hashicorp/google v3.72.0
+ provider registry.terraform.io/hashicorp/google-beta v3.72.0
+ provider registry.terraform.io/hashicorp/local v2.1.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/newrelic/newrelic v2.23.0
```
### Terraform Configuration Files
[sample.zip](https://github.com/hashicorp/terraform-provider-google/files/6785672/sample.zip)
### Debug Output
N/A
### Crash Output
N/A
### Expected Behavior
The code should create one dynamic subnet block
### Actual Behavior
Terraform fails with an ExactlyOne error:
```
╷
│ Error: ExactlyOne
│
│ with module.network.google_vpc_access_connector.connector,
│ on main.tf line 25, in resource "google_vpc_access_connector" "connector":
│ 25: resource "google_vpc_access_connector" "connector" {
│
│ "network": one of `network,subnet.0.name` must be specified
╵
```
### Steps to Reproduce
1. Extract [sample.zip](https://github.com/hashicorp/terraform-provider-google/files/6785672/sample.zip)
2. Run terraform init
3. Run terraform apply (it should fail with the error)
4. Change the line 21 from var to local (it is the same data), and the apply will work
### Additional Context
This seems to be an error related to how dynamic block is calculated for composed required fields
### References
- https://github.com/hashicorp/terraform-provider-google/issues/9515
Contributor guide
Research direction
Extract sample.zip and read main.tf around lines 21 and 25, then run terraform init and terraform apply to reproduce the ExactlyOne error. Compare the variable-based dynamic block with the local-based version and investigate how composed required fields are calculated. Done means the variable-based configuration creates one dynamic subnet block without the error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100