Loading...
Loading...
### Terraform Version ```shell v1.12.0-dev (8865218ccb584267a558b4d0c6f0c14a2d1aefd0) ``` ### Terraform Configuration Files ```terraform terraform { required_providers { restful = { source = "magodo/restful" } } } provider "restful" { base_url = "http://local:3000" } ephemeral "restful_resource" "test" { path = "/ephemerals" method = "POST" renew_path = "/ephemerals/$(body.id)" renew_method = "PATCH" renew_body = { renew = 1 } expiry_type = "duration" expiry_locator = "exact.1s" close_path = "/ephemerals/$(body.id)" close_method = "DELETE" } resource "restful_resource" "test" { path = "/resources" read_path = "/resources/$(body.id)" body = { foo = "bar" } ephemeral_body = { secret = ephemeral.restful_resource.test.output.id } } ``` ### Debug Output ``` ╷ │ Error: Invalid use of ephemeral value │ │ with restful_resource.test, │ on main.tf line 30, in resource "restful_resource" "test": │ 30: resource "restful_resource" "test" { │ │ Ephemeral values are not valid for "ephemeral_body.secret", because it is not an assignable │ attribute. ╵ ``` ### Expected Behavior Terraform should accept this config as `ephemeral_body` is marked as `WriteOnly: true`, albeit it is of dynamic type. ### Actual Behavior `terraform validate` failed with error: ``` ╷ │ Error: Invalid use of ephemeral value │ │ with restful_resource.test, │ on main.tf line 30, in resource "restful_resource" "test": │ 30: resource "restful_resource" "test" { │ │ Ephemeral values are not valid for "ephemeral_body.secret", because it is not an assignable │ attribute. ╵ ``` ### Steps to Reproduce 1. Checkout and build the `magodo/terraform-provider-restful` at branch: https://github.com/magodo/terraform-provider-restful/tree/ephemeral_body 2. Instruct terraform to use the locally built provider via modifying the `.terraformrc` 3. `terraform validate` with the config above ### Additional Context Since the write-only attribute support [PR](https://github.com/hashicorp/terraform-plugin-framework/pull/1044) is merged in FW recently, I'm trying to support that in my [restful provider](https://github.com/magodo/terraform-provider-restful/tree/ephemeral_body). The provider offers a general resource `restful_resource`, whose `body` is defined as a dynamic value. For the same reason, I've introduced a new optional attribute `ephemeral_body` which has the `WriteOnly: true`, and is also a dynamic value. I expect as long the `ephemeral_body` is marked as write-only, then it can reference a ephemeral value. However, it turns out I can only directly assign an ephemeral value to `ephemeral_body`, but can't assign it to a nested field. I find the error is raised from Terraform, therefore submitting the issue here. ### References _No response_ ### Generative AI / LLM assisted development? _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.