Fix elasticstack_kibana_data_view forced replacement due to auto-calculated field_attrs count#1352
Fix elasticstack_kibana_data_view forced replacement due to auto-calculated field_attrs count#1352
Conversation
|
@copilot , create test to reproduce the issue, e.g. in |
|
@copilot , a possible fix is to add Also, maybe Optional can be removed.
|
…attrs count Co-authored-by: dimuon <[email protected]>
Co-authored-by: dimuon <[email protected]>
I've added
Added acceptance test |
|
bump, still relevant, changing ids can easily break dashboards that depend on those data views |
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.