Skip to content

feat(secure): add sysdig_secure_zone_posture_policy_assignment resource#726

Merged
tembleking merged 4 commits into
masterfrom
feat/zone-posture-policy-assignment
May 5, 2026
Merged

feat(secure): add sysdig_secure_zone_posture_policy_assignment resource#726
tembleking merged 4 commits into
masterfrom
feat/zone-posture-policy-assignment

Conversation

@tembleking
Copy link
Copy Markdown
Member

@tembleking tembleking commented Apr 16, 2026

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

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.

Comment thread website/docs/r/secure_zone_posture_policy_assignment.md
tembleking added 2 commits May 4, 2026 11:30
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
@tembleking tembleking force-pushed the feat/zone-posture-policy-assignment branch from 302fbc2 to 02201c5 Compare May 4, 2026 09:45
Extract provider docs validation into a reusable Makefile target so it
can run locally. CI workflow now delegates to make provider-docs.
Copilot AI review requested due to automatic review settings May 4, 2026 10:00
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

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


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

Comment thread sysdig/internal/client/v2/model.go
Comment thread GNUmakefile
…sponse

API returns both zoneId and policyIds as JSON strings, not numbers.
Copy link
Copy Markdown

@alecron alecron left a comment

Choose a reason for hiding this comment

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

LGTM

@tembleking tembleking added this pull request to the merge queue May 5, 2026
Merged via the queue into master with commit 4769b76 May 5, 2026
180 checks passed
@tembleking tembleking deleted the feat/zone-posture-policy-assignment branch May 5, 2026 13:42
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.

4 participants