Skip to content

Invalid plan error when using lifecycle ignore_changes with deprecated relationship fields (DCNE-548) #1379

@jasonjuenger

Description

@jasonjuenger

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v1.5.7
terraform-provider-aci v2.17.0

APIC version and APIC Platform

  • V 5.2(8e) and on-prem

Affected Resource(s)

  • aci_tenant
  • aci_vrf
  • (Likely other resources with deprecated relationship fields migrated to terraform-plugin-framework)

Terraform Configuration Files

# Minimal reproduction case - tenant resource with lifecycle ignore_changes
resource "aci_tenant" "test" {
  name        = "test-tenant"
  description = "Test tenant for bug reproduction"
  
  # This lifecycle block should prevent drift on deprecated fields
  # but instead causes "Provider produced invalid plan" errors
  lifecycle {
    ignore_changes = [
      relation_fv_rs_tenant_mon_pol,
    ]
  }
}

# VRF resource showing same issue with multiple relationship fields
resource "aci_vrf" "test" {
  parent_dn   = aci_tenant.test.id
  name        = "test-vrf"
  description = "Test VRF for bug reproduction"
  
  lifecycle {
    ignore_changes = [
      relation_fv_rs_bgp_ctx_pol,
      relation_fv_rs_ctx_to_ep_ret,
      relation_fv_rs_ctx_to_ext_route_tag_pol,
      relation_fv_rs_ospf_ctx_pol,
    ]
  }
}

Debug Output

Debug output shows the provider is generating plan values that do not conform to Terraform's planning rules. The provider forces plan values to "default" even when configuration has empty strings and lifecycle ignore_changes is set.

Panic Output

None, this is a tf plan error.

Expected Behavior

When lifecycle { ignore_changes } is specified for relationship fields:

  1. Plan generation should respect ignore_changes
  2. If a field is not configured or set to empty string, the plan should reflect that, not replace the empty string with "default"
  3. The provider should not push changes to ACI for fields in ignore_changes
  4. terraform plan should complete successfully without "Provider produced invalid plan" errors

Actual Behavior

The provider generates an "invalid plan" error that violates Terraform's core planning rules:

Error: Provider produced invalid plan

Provider "registry.terraform.io/ciscodevnet/aci" planned an invalid value
for aci_tenant.test.relation_to_monitoring_policy.monitoring_policy_name:
planned value cty.StringVal("default") does not match config value
cty.StringVal("") nor prior value cty.StringVal("").

This is a bug in the provider, which should be reported in the provider's
own issue tracker.

Steps to Reproduce

  1. Import existing ACI tenant/VRF resources that do not have monitoring policies assigned in ACI (ex. "")
  2. Configure terraform resources without specifying relationship fields
  3. Add lifecycle { ignore_changes } for deprecated relationship fields
  4. Run terraform plan
  5. Observe "Provider produced invalid plan" error

Important Factoids

  • There does not appear to be a workaround for this issue. Configuring the fields with empty strings, omitting them, or using lifecycle ignore_changes does not resolve the issue
  • When relationship fields are configured, the provider pushes actual changes to ACI (empty strings become "default" policies). This applies both to the deprecated fields and the new fields that replace those deprecated fields.

References

  • Provider Framework Migration: This appears related to the migration from terraform-plugin-sdk/v2 to terraform-plugin-framework starting in v2.16.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    jira-syncSync this issue to Jira

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions