Fix elasticstack_kibana_data_view forced replacement due to auto-calculated field_attrs count #1352
+164
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The
elasticstack_kibana_data_viewresource was unexpectedly forcing replacement when users interacted with the data view in Kibana. This occurred because Kibana automatically generates field popularity statistics (specifically thecountattribute withinfield_attrs) when users explore data, and Terraform detected these server-side changes as configuration drift.Root Cause
The
countattribute infield_attrswas defined asOptional: trueonly, which meant:field_attrshas aRequiresReplace()plan modifier, any detected change triggered resource replacementSolution
Modified the
countattribute schema to handle server-side updates gracefully:This change makes the attribute both user-configurable and server-computed, allowing Terraform to accept server-side updates without triggering replacement while still permitting users to explicitly set values when desired.
Testing
TestAccResourceDataViewFieldAttrsReproduceIssuethat reproduces the exact issue described in the problem statementTestAccResourceDataViewvalidates the fix works end-to-endImpact
This resolves the core idempotency issue described in the original bug report, ensuring that
terraform planshows no changes after the initial creation, regardless of data view usage in Kibana.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.