feat(terraform): add panos_ip_tag resource and data source#728
Open
migara wants to merge 1 commit into
Open
Conversation
Add a custom resource and data source for PAN-OS dynamic IP-to-tag registration via the User-ID API (op/user-id, no candidate config and no commit). Resource (panos_ip_tag): - Registers a managed set of tags against an IP; non-destructive and idempotent (re-registering existing tags is a no-op). - Real Update: registers added tags, unregisters removed tags; an IP change moves the managed tags. Tags not managed by the resource are never touched. - Drift reconciliation stores only managed tags still present on the firewall; the resource is removed from state when none remain. - Three locations: vsys (NGFW), panorama (Panorama's own User-ID table), and target_device (Panorama-managed firewall by serial). Data source (panos_ip_tag): - Single-IP lookup: given a location and ip, returns every tag currently registered on that IP (empty set if none). Docs include the drift-reconciliation example and the overlap-ownership limitation (the firewall has no refcount for registered tags). Tested with white-box unit specs (tag-set diff, register/unregister marshaling, paginated response parsing) and acceptance tests covering the resource lifecycle + CheckDestroy and the data-source read, both verified live against Panorama. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| - "config" | ||
| - "shared" | ||
| vars: [] | ||
| - name: "target-device" |
Contributor
There was a problem hiding this comment.
Is this location specific for IP tags?
Member
Author
There was a problem hiding this comment.
It's blanket implementation. No location. The spec location is dummy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a custom resource and data source for PAN-OS dynamic IP-to-tag registration via the User-ID API. These registrations live in the firewall's User-ID table (runtime state), not the candidate config — so there is no commit and the resource is not importable (adopt by declaring and applying; registration is idempotent).
panos_ip_tagresourcevsys(NGFW),panorama(Panorama's own User-ID table),target_device(Panorama-managed firewall by serial).panos_ip_tagdata sourcelocationandip, returns every tag currently registered on that IP (empty set if none).Docs
Design note
The data source is a single-IP lookup rather than a filtered listing (ip/tag filters → entries + total). A listing shape isn't expressible in this codegen: a custom data source's model is fixed to the spec params, a fully hand-written data source can't be registered (the provider's
DataSources()list is generated), and there's no datasource-only param override. The single-IP lookup is the codegen-native shape.Testing
TF_ACC, live-verified against Panorama): resource create → update-tags → delete withCheckDestroy, and the data-source read. Both passing live.Notes for reviewers
A self-review surfaced several non-blocking cleanup/test-quality items to revisit in follow-ups (e.g. the live read path bypasses the unit-tested
toMap/parseRegisteredIpResponsedecode path;CheckDestroydoesn't paginate; deadtagFilterparam; concrete*pango.Clientvs theutil.PangoClientconvention). None affect correctness of the shipped behavior.🤖 Generated with Claude Code