Skip to content

feat(secure): add sysdig_secure_zone_posture_policy_assignment resource#726

Open
tembleking wants to merge 1 commit intomasterfrom
feat/zone-posture-policy-assignment
Open

feat(secure): add sysdig_secure_zone_posture_policy_assignment resource#726
tembleking wants to merge 1 commit intomasterfrom
feat/zone-posture-policy-assignment

Conversation

@tembleking
Copy link
Copy Markdown
Member

New resource sysdig_secure_zone_posture_policy_assignment that manages the association between a sysdig_secure_zone and a set of posture policy IDs via the CSPM API (/api/cspm/v1/zones/{zoneId}/policies).

This is a standalone resource (not embedded in sysdig_secure_zone) because the APIs have different lifecycles and it allows assigning policies to system zones the user didn't create. The resource ID is the zone ID (1:1 relationship), and zone_id is ForceNew since changing it means a different resource.

Depends on backend routing enablement: draios/sysdigcloud-harness-cd#75479

Ref: ET-836

Manages the association between a sysdig_secure_zone and a set of
posture policy IDs via the CSPM API (PUT /api/cspm/v1/zones/{zoneId}/policies).

This is a standalone resource (not embedded in sysdig_secure_zone)
because the APIs have different lifecycles and it allows assigning
policies to system zones the user didn't create.

Ref: ET-836
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

Adds a new Terraform resource to manage CSPM posture-policy assignments for Secure Zones via the /api/cspm/v1/zones/{zoneId}/policies API, enabling policy management for both user-created and system zones as a standalone lifecycle.

Changes:

  • Introduces sysdig_secure_zone_posture_policy_assignment resource with CRUD + import (resource ID = zone ID).
  • Adds a v2 client implementation (ZonePolicyAssignmentInterface) and models for the new CSPM endpoint.
  • Adds acceptance coverage and provider registration, plus new user documentation for the resource.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
website/docs/r/secure_zone_posture_policy_assignment.md New documentation page for the resource, including example usage and import.
sysdig/resource_sysdig_secure_zone_posture_policy_assignment.go Implements the Terraform resource schema and CRUD operations.
sysdig/resource_sysdig_secure_zone_posture_policy_assignment_test.go Adds acceptance test coverage for create/update/import flows.
sysdig/provider.go Registers the new resource in the provider.
sysdig/internal/client/v2/zone_policy_assignment.go Adds v2 API client methods for zone policy assignments.
sysdig/internal/client/v2/model.go Adds request/response structs for the new endpoint.
sysdig/internal/client/v2/client.go Extends SecureCommon to include the new interface.
sysdig/common.go Adds a shared SchemaZoneIDKey constant used by the new resource.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

data "sysdig_secure_posture_policy" "p2" {
id = 1

# Resource: sysdig_secure_zone_posture_policy_assignment

Manages the association between a [`sysdig_secure_zone`](secure_zone.html) and a set of posture policy IDs.
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.

2 participants