Skip to content

feat(secure): add name-based lookup to sysdig_secure_posture_policy data source#723

Merged
tembleking merged 1 commit intomasterfrom
feat/posture-policy-name-lookup
Apr 7, 2026
Merged

feat(secure): add name-based lookup to sysdig_secure_posture_policy data source#723
tembleking merged 1 commit intomasterfrom
feat/posture-policy-name-lookup

Conversation

@tembleking
Copy link
Copy Markdown
Member

Summary

The sysdig_secure_posture_policy data source now supports lookup by name in addition to id, using ExactlyOneOf validation. Name lookup lists all policies, filters by exact match, then fetches the full detail by ID.

  • Add name as optional input with ExactlyOneOf id/name
  • Make id optional (was required)
  • Two-step name lookup: list policies, match name, fetch full detail by ID
  • Add acceptance test for name-based lookup
  • Update documentation with both lookup examples

…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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 name as an optional input parameter with ExactlyOneOf validation paired with id
  • Make id optional (previously required) with ExactlyOneOf validation
  • 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.

@tembleking tembleking merged commit cb59e61 into master Apr 7, 2026
201 of 358 checks passed
@tembleking tembleking deleted the feat/posture-policy-name-lookup branch April 7, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants