fix(ise): mark groups and rewrite_rules as computed on active_directory_join_point - #261
Conversation
…ry_join_point The groups and rewrite_rules attributes were not marked Computed. During brownfield import, ISE returns existing groups in the GET response, populating Terraform state. On the next plan, Terraform detected a diff between the imported state (groups present) and the config (groups absent or empty), causing it to plan a destroy and recreate of the join point resource. Destroying a join point means leaving and re-joining the domain, disrupting authentication for all endpoints using that AD integration. Mark groups and rewrite_rules as Computed: true and introduce a PreserveStateIfUnconfigured plan modifier. When the attribute is omitted from config, the modifier preserves whatever is in state, eliminating the spurious diff and preventing the destroy/recreate cycle. On first create with no prior state, it returns null cleanly, avoiding the type-conversion error that listplanmodifier.UseStateForUnknown() causes on nested list attributes. Fixes CiscoDevNet#260 Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
… fix Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
rafal-slominskii
left a comment
There was a problem hiding this comment.
Hi, two small things, commented in code.
…evels and restrict to nested lists only The plan modifier was applied only to nesting levels 1-3 in the resource template, leaving levels 4-7 with UseStateForUnknown(). Also, the condition used was isNestedListSet which matches both List and Set types, but PreserveStateIfUnconfigured is a planmodifier.List and cannot satisfy the planmodifier.Set interface. Add the isNestedList guard to the Computed PlanModifiers block at levels 4-7. Replace isNestedListSet with isNestedList at all seven levels so Set attributes continue to use UseStateForUnknown() and the modifier is never emitted where it would cause a compile error. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Hey @rafal-slominskii, thank you for your feedback. I've addressed both issues below. Let me know if you think any other changes should be made. Comment 1 (levels 4–7): The Comment 2 ( |
Resolved changelog conflicts by adding the active_directory_join_point fix entry to the new 0.4.1 (unreleased) section.
Summary
Fixes #260
Root cause: The
groupsandrewrite_rulesattributes onise_active_directory_join_pointwere not markedComputed. In a brownfield import scenario, ISE returns the existing groups in the GET response, populating Terraform state. On the nextterraform plan, Terraform detected a diff between the imported state (groups present) and the config (groups omitted), and planned to destroy and recreate the join point to reconcile it. Destroying a join point means leaving and re-joining the domain, disrupting authentication for all endpoints relying on that AD integration.Impact: Any brownfield import of
ise_active_directory_join_pointwhere the ISE join point has associated groups results in a planned destroy/recreate on the firstterraform planafter import.Fix: Mark
groupsandrewrite_rulesasComputed: trueand introduce aPreserveStateIfUnconfiguredplan modifier. When either attribute is omitted from config, the modifier preserves whatever is in state, eliminating the spurious diff and preventing the destroy/recreate cycle. On first create with no prior state, it returnsnullcleanly — avoiding the type-conversion error thatlistplanmodifier.UseStateForUnknown()produces on nested list attributes.Changes
gen/definitions/active_directory_join_point.yaml— addcomputed: truetogroupsandrewrite_rulesattributesgen/templates/resource.go— applyPreserveStateIfUnconfigured()instead ofUseStateForUnknown()when a computed attribute is a nested list or setinternal/provider/helpers/plan_modifiers.go— implementPreserveStateIfUnconfiguredplan modifierinternal/provider/resource_ise_active_directory_join_point.go— regeneratedTest plan
Brownfield import of an
ise_active_directory_join_pointthat has three AD groups managed byise_active_directory_add_groups. Groups are provided in config with explicit SIDs.YAML config used:
terraform plan+terraform apply(brownfield import):The join point is imported with groups present in state. The plan shows the join point as
will be imported(not destroyed), andise_active_directory_add_groupsis created to manage the groups going forward.terraform planafter apply — no drift:🤖 AI Generation Metadata