elastic / elastic/terraform-provider-elasticstack
[Bug] elasticstack_fleet_integration_policy: v1→v3 state upgrade fails with "unsupported attribute \"enabled\"" after upgrading v0.13.2 → v0.16.2
- Dominant language
- Go
- Stars
- 209
- Forks
- 150
- Avg merge
- 23h 11m
- Merged PRs (30d)
- 169
Description
After upgrading `elasticstack_fleet_integration_policy` resources from provider v0.13.2 to v0.16.2, `terraform apply` fails with:
`Error decoding "module.elastic.elasticstack_fleet_integration_policy.this[\"\"]" from prior state: unsupported attribute "enabled"`
This occurs even though the affected resource's prior state is `schema_version: 1`, and the provider explicitly registers a state upgrader for that version (`upgradeV1ToV3`, see `UpgradeState` in [internal/fleet/integration_policy/resource.go](https://github.com/elastic/terraform-provider-elasticstack/blob/main/internal/fleet/integration_policy/resource.go). We inspected the raw state for one affected instance and confirmed it matches [schema v1](https://github.com/elastic/terraform-provider-elasticstack/blob/main/internal/fleet/integration_policy/schema_v1.go) exactly — singular `input` list block, each entry with `input_id/enabled/streams_json/vars_json`, no structural drift. Despite that exact match, the v1→v3 upgrade does not complete successfully. Multiple integration policy resources managed via `for_each` are affected, not just one.
To Reproduce
1) TF configuration used:
```
resource "elasticstack_fleet_integration_policy" "this" {
for_each = var.integrations
name = each.value.name
namespace = each.value.namespace
agent_policy_id = each.value.agent_policy_id
integration_name = each.value.integration_name
integration_version = each.value.integration_version
input {
input_id = ""
enabled = true
streams_json = jsonencode({
"" = {
enabled = true
vars = {
"" = ""
}
}
})
}
}
```
2) Existing state was created/applied under provider ~> 0.13.2.
3) Updated required_providers to ~> 0.16.2, then ran:
```
terraform init -upgrade
terraform apply
```
4) Error observed:
`Error decoding "module.elastic.elasticstack_fleet_integration_policy.this[\"\"]" from prior state: unsupported attribute "enabled"`
**Expected behavior:**
The v1 → v3 state upgrader (introduced alongside removal of the top-level enabled attribute in [v0.15.0](https://github.com/elastic/terraform-provider-elasticstack/blob/main/CHANGELOG.md#0150---2026-05-13) / [PR #2773](https://github.com/elastic/terraform-provider-elasticstack/pull/2773) should transparently migrate existing v1 state and drop enabled, allowing terraform apply to proceed without error.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with UpgradeState and upgradeV1ToV3 in internal/fleet/integration_policy/resource.go, comparing their behavior with the schema in internal/fleet/integration_policy/schema_v1.go. Reproduce the v0.13.2 to v0.16.2 upgrade using the for_each configuration and inspect why the v1 state containing enabled is rejected. Done means existing v1 resources upgrade successfully and terraform apply completes without the unsupported attribute error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, terraform
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100