Loading...
Loading...
### Terraform Version ```shell Terraform v1.11.1 ``` ### Terraform Configuration Files ```terraform resource "terraform_data" "force_deferral" { input = "hello" } data "examplecloud_thing" "test" { nested_map = { "key1" : { required_attr = terraform_data.force_deferral.output # computed_attr } } nested_obj = { required_attr = terraform_data.force_deferral.output # computed_attr } } output "test" { value = data.examplecloud_thing.test } ``` #### Plugin Framework schema for reference ```go resp.Schema = schema.Schema{ Attributes: map[string]schema.Attribute{ "nested_map": schema.MapNestedAttribute{ Optional: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "required_attr": schema.StringAttribute{ Required: true, }, "computed_attr": schema.StringAttribute{ Computed: true, }, }, }, }, "nested_obj": schema.SingleNestedAttribute{ Optional: true, Attributes: map[string]schema.Attribute{ "required_attr": schema.StringAttribute{ Required: true, }, "computed_attr": schema.StringAttribute{ Computed: true, }, }, }, }, } ``` ### Debug Output ```bash # ... most of the log is not useful, but the one showing that the provider isn't involved in the read 2025-03-07T08:52:53.536-0500 [TRACE] planDataSource: data.examplecloud_thing.test configuration not fully known yet, so deferring to apply phase ``` Full gist if you're interested: https://gist.github.com/austinvalle/09ce975db66669fc13751e3da91d5036 ### Expected Behavior ```sh Plan: 1 to add, 0 to change, 0 to destroy. Changes to Outputs: + test = { + nested_map = { + key1 = { + computed_attr = (known after apply) # <------- + required_attr = (known after apply) } } + nested_obj = { + computed_attr = (known after apply) + required_attr = (known after apply) } } ``` ### Actual Behavior When a data source is deferred to the apply phase, Terraform core creates a plan via [`PlannedDataResourceObject`](https://github.com/hashicorp/terraform/blob/9ac4b3a62b7295ae2060e24c8d04f5f7d149bf8d/internal/plans/objchange/objchange.go#L64) on the providers behalf. For computed attributes that are nested under a nested map type, it looks like Terraform is planning the config value (``) value instead of the prior value (`` for deferred data resources). I compared this behavior with a single (object) nested type with a computed attribute, which looks to be planning an `` properly. ----------- It looks like the `objchange` logic for nested map types is only using the prior map value (which is all unknowns for deferred data resources) when the map is known, which results in the `configVal` being taken for the computed attribute (``), rather than `` https://github.com/hashicorp/terraform/blob/9ac4b3a62b7295ae2060e24c8d04f5f7d149bf8d/internal/plans/objchange/objchange.go#L242-L246 ```sh Plan: 1 to add, 0 to change, 0 to destroy. Changes to Outputs: + test = { + nested_map = { + key1 = { + computed_attr = null # I'd expect this to be unknown + required_attr = (known after apply) } } + nested_obj = { + computed_attr = (known after apply) + required_attr = (known after apply) } } ``` ### Steps to Reproduce The provider shown isn't published, but you can build it from source if you need (or I can help debug further, just ping me on HC slack 😆) https://github.com/austinvalle/terraform-provider-sandbox/tree/main 1. `terraform plan` (no init since it's from source/reattached) ### Additional Context _No response_ ### References - **Original plugin framework issue:** https://github.com/hashicorp/terraform-plugin-framework/issues/1102 - **Provider specific issue:** https://github.com/marshallford/terraform-provider-ansible/issues/79 ### 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.