Skip to content

Conversation

@ChihweiLHBird
Copy link

Related Issue

Fixes #1214

Description

The UseStateForUnknownIf plan modifier can copy the state value into plan when the condition is met.

There are some common cases to use this plan modifier, for example:

  1. A computed attribute is only changed during an update operation when another attribute is being changed.
  2. ...

Signed-off-by: Zhiwei Liang <zhiwei.liang27@pm.me>
Copilot AI review requested due to automatic review settings January 21, 2026 21:45
@ChihweiLHBird ChihweiLHBird force-pushed the zhiwei/use-state-for-unknown-if branch from a4585e0 to bd20dea Compare January 21, 2026 21:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements the UseStateForUnknownIf plan modifier across all Terraform attribute types, enabling conditional preservation of state values when plan values are unknown.

Changes:

  • Adds UseStateForUnknownIf plan modifier for 12 attribute types (string, bool, int32, int64, float32, float64, number, dynamic, list, map, set, object)
  • Includes conditional function types and response structures for each type
  • Provides comprehensive test coverage with 6 test cases per type

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated no comments.

Show a summary per file
File Description
resource/schema/stringplanmodifier/use_state_for_unknown_if.go Implements conditional plan modifier for string type
resource/schema/stringplanmodifier/use_state_for_unknown_if_func.go Defines conditional function type and response for string type
resource/schema/stringplanmodifier/use_state_for_unknown_if_test.go Tests for string type plan modifier
resource/schema/boolplanmodifier/* Same pattern for bool type
resource/schema/int32planmodifier/* Same pattern for int32 type
resource/schema/int64planmodifier/* Same pattern for int64 type
resource/schema/float32planmodifier/* Same pattern for float32 type
resource/schema/float64planmodifier/* Same pattern for float64 type
resource/schema/numberplanmodifier/* Same pattern for number type
resource/schema/dynamicplanmodifier/* Same pattern for dynamic type
resource/schema/listplanmodifier/* Same pattern for list type
resource/schema/mapplanmodifier/* Same pattern for map type
resource/schema/setplanmodifier/* Same pattern for set type
resource/schema/objectplanmodifier/* Same pattern for object type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plan Modifier UseStateForUnknownIf

1 participant