Skip to content

Conversation

@fivetran-jovanmanojlovic
Copy link
Contributor

  • Added UseStateForUnknown() plan modifier to prevent noisy terraform plan output
  • Changed is_primary_key from Optional+Computed to Computed-only (read-only field)
  • Applied to both new schemas format and legacy schema format
  • Eliminates unnecessary '(known after apply)' diffs for unchanged primary key attributes

Root cause: Previous fixes (v1.9.9-v1.9.11) tried model-based approaches, but the standard Terraform Framework solution is UseStateForUnknown plan modifier. This tells Terraform to use the state value for unchanged computed fields during plan.

Without this modifier, Optional+Computed attributes show as '(known after apply)' for every column, making plan output unreadable for large schemas (hundreds of tables).

Testing:

  • All existing unit tests pass
  • TestResourceSchemaPrimaryKeyComputedMock: validates no is_primary_key in PATCH
  • TestResourceSchemaPrimaryKeyNullDefaultMock: validates null defaults
  • TestResourceSchemaPrimaryKeyLargeSchemaNoNoiseMock: validates at scale
  • Manual terraform plan test: confirms no is_primary_key noise in output

- Added UseStateForUnknown() plan modifier to prevent noisy terraform plan output
- Changed is_primary_key from Optional+Computed to Computed-only (read-only field)
- Applied to both new schemas format and legacy schema format
- Eliminates unnecessary '(known after apply)' diffs for unchanged primary key attributes

Root cause: Previous fixes (v1.9.9-v1.9.11) tried model-based approaches, but the
standard Terraform Framework solution is UseStateForUnknown plan modifier. This tells
Terraform to use the state value for unchanged computed fields during plan.

Without this modifier, Optional+Computed attributes show as '(known after apply)' for
every column, making plan output unreadable for large schemas (hundreds of tables).

Testing:
- All existing unit tests pass
- TestResourceSchemaPrimaryKeyComputedMock: validates no is_primary_key in PATCH
- TestResourceSchemaPrimaryKeyNullDefaultMock: validates null defaults
- TestResourceSchemaPrimaryKeyLargeSchemaNoNoiseMock: validates at scale
- Manual terraform plan test: confirms no is_primary_key noise in output
@fivetran-jovanmanojlovic fivetran-jovanmanojlovic marked this pull request as ready for review November 27, 2025 15:03
- Bumped provider version from 1.9.15 to 1.9.16
- Added CHANGELOG entry documenting the is_primary_key fix
- Documents that UseStateForUnknown plan modifier eliminates noisy plan output
Copy link
Contributor

@fivetran-renat-sh fivetran-renat-sh left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you!

@fivetran-jovanmanojlovic fivetran-jovanmanojlovic merged commit 696dcf8 into main Dec 1, 2025
1 check passed
@fivetran-jovanmanojlovic fivetran-jovanmanojlovic deleted the fix-noisy-plan-output-use-state-for-unknown branch December 1, 2025 09:30
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.

2 participants