Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tfsdk: Check ProposedNewState for State differences before marking un…
…knowns for Computed-only attributes in plans (#184) * tfsdk: Check ProposedNewState for State differences before marking unknowns for Computed-only attributes in plans Reference: #181 Previously, any `Computed` attributes would always trigger plan differences due to the unknown marking. ``` Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: ~ update in-place Terraform will perform the following actions: # hashicups_order.edu will be updated in-place ~ resource "hashicups_order" "edu" { ~ id = "1" -> (known after apply) ~ items = [ ~ { ~ coffee = { + description = (known after apply) id = 3 ~ image = "/nomad.png" -> (known after apply) ~ name = "Nomadicano" -> (known after apply) ~ price = 150 -> (known after apply) ~ teaser = "Drink one today and you will want to schedule another" -> (known after apply) } # (1 unchanged attribute hidden) ~ coffee = { + description = (known after apply) id = 1 ~ image = "/packer.png" -> (known after apply) ~ name = "Packer Spiced Latte" -> (known after apply) ~ price = 350 -> (known after apply) ~ teaser = "Packed with goodness to spice up your images" -> (known after apply) } # (2 unchanged attributes hidden) }, ] ~ last_updated = "Tuesday, 28-Sep-21 11:53:27 EDT" -> (known after apply) } Plan: 0 to add, 1 to change, 0 to destroy. ``` This change limits the unknown marking to only be performed when there is actually a change between the `ProposedNewState` and `State`. Without a configuration change: ``` No changes. Your infrastructure matches the configuration. ``` With a configuration change: ``` Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: ~ update in-place Terraform will perform the following actions: # hashicups_order.edu will be updated in-place ~ resource "hashicups_order" "edu" { ~ id = "1" -> (known after apply) ~ items = [ ~ { ~ coffee = { + description = (known after apply) id = 3 ~ image = "/nomad.png" -> (known after apply) ~ name = "Nomadicano" -> (known after apply) ~ price = 150 -> (known after apply) ~ teaser = "Drink one today and you will want to schedule another" -> (known after apply) } # (1 unchanged attribute hidden) ~ coffee = { + description = (known after apply) ~ id = 1 -> 2 ~ image = "/packer.png" -> (known after apply) ~ name = "Packer Spiced Latte" -> (known after apply) ~ price = 350 -> (known after apply) ~ teaser = "Packed with goodness to spice up your images" -> (known after apply) } # (2 unchanged attributes hidden) }, ] ~ last_updated = "Tuesday, 28-Sep-21 11:53:27 EDT" -> (known after apply) } Plan: 0 to add, 1 to change, 0 to destroy. ``` As a followup, it may be necessary to invoke two passes of attribute and resource plan modifiers to ensure any changes captured by those modifiers triggers the unknown marking. As it stands now, a plan with no configuration changes, but changes due to plan modifiers will not correctly trigger the unknown marking. See also: #183 Co-authored-by: Katy Moe <katy@katy.moe>
- Loading branch information