feat(secure): add name-based lookup to sysdig_secure_posture_policy data source#723
Merged
tembleking merged 1 commit intomasterfrom Apr 7, 2026
Merged
Conversation
…ata source Support looking up a posture policy by name in addition to ID, using ExactlyOneOf validation. Name lookup lists all policies and filters by exact match, then fetches the full detail. Ref: ET-819
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds name-based lookup functionality to the sysdig_secure_posture_policy data source, allowing users to retrieve policies by name in addition to ID. The implementation uses Terraform's ExactlyOneOf validation to ensure exactly one of id or name is provided.
Changes:
- Add
nameas an optional input parameter withExactlyOneOfvalidation paired withid - Make
idoptional (previously required) withExactlyOneOfvalidation - Implement two-step name lookup: list all policies, find matching name, fetch full details by ID
- Add acceptance test for name-based lookup functionality
- Update documentation with examples for both ID and name-based lookups, and fix a typo in the data source block syntax
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
website/docs/d/secure_posture_policy.md |
Updated documentation to describe name-based lookup, added examples for both ID and name, fixed typo in data source syntax |
sysdig/data_source_sysdig_secure_posture_policy.go |
Added logic to handle name-based lookup using ListPosturePolicies and improved error messages with fmt.Errorf |
sysdig/data_source_sysdig_secure_posture_policy_test.go |
Added acceptance test for name-based lookup that verifies policy ID and name |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
airadier
approved these changes
Apr 6, 2026
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
The
sysdig_secure_posture_policydata source now supports lookup bynamein addition toid, usingExactlyOneOfvalidation. Name lookup lists all policies, filters by exact match, then fetches the full detail by ID.nameas optional input withExactlyOneOfid/nameidoptional (was required)