diff --git a/sysdig/data_source_sysdig_secure_posture_zone.go b/sysdig/data_source_sysdig_secure_posture_zone.go index fc07cc93..5b1b8d96 100644 --- a/sysdig/data_source_sysdig_secure_posture_zone.go +++ b/sysdig/data_source_sysdig_secure_posture_zone.go @@ -10,7 +10,8 @@ import ( func dataSourceSysdigSecurePostureZone() *schema.Resource { return &schema.Resource{ - ReadContext: dataSourceSysdigSecurePostureZoneRead, + DeprecationMessage: "sysdig_secure_posture_zone is deprecated and will be removed in a future version. Use sysdig_secure_zone instead.", + ReadContext: dataSourceSysdigSecurePostureZoneRead, Schema: map[string]*schema.Schema{ "id": { diff --git a/sysdig/resource_sysdig_secure_posture_zone.go b/sysdig/resource_sysdig_secure_posture_zone.go index 45036108..4c9b840f 100644 --- a/sysdig/resource_sysdig_secure_posture_zone.go +++ b/sysdig/resource_sysdig_secure_posture_zone.go @@ -14,10 +14,11 @@ func resourceSysdigSecurePostureZone() *schema.Resource { timeout := 5 * time.Minute return &schema.Resource{ - CreateContext: resourceCreateOrUpdatePostureZone, - UpdateContext: resourceCreateOrUpdatePostureZone, - DeleteContext: resourceSysdigSecurePostureZoneDelete, - ReadContext: resourceSysdigSecurePostureZoneRead, + DeprecationMessage: "sysdig_secure_posture_zone is deprecated and will be removed in a future version. Use sysdig_secure_zone instead.", + CreateContext: resourceCreateOrUpdatePostureZone, + UpdateContext: resourceCreateOrUpdatePostureZone, + DeleteContext: resourceSysdigSecurePostureZoneDelete, + ReadContext: resourceSysdigSecurePostureZoneRead, Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, }, diff --git a/website/docs/d/secure_posture_zone.md b/website/docs/d/secure_posture_zone.md index 8068419b..25a98e33 100644 --- a/website/docs/d/secure_posture_zone.md +++ b/website/docs/d/secure_posture_zone.md @@ -8,6 +8,8 @@ description: |- # sysdig_secure_posture_zone Data Source +~> **Deprecated:** `sysdig_secure_posture_zone` is deprecated and will be removed in a future version. Use [`sysdig_secure_zone`](secure_zone) instead. + The `sysdig_secure_posture_zone` data source allows you to retrieve information about a specific secure posture zone by its ID. ## Example Usage diff --git a/website/docs/r/secure_posture_zone.md b/website/docs/r/secure_posture_zone.md index c4d7fa34..b4562787 100644 --- a/website/docs/r/secure_posture_zone.md +++ b/website/docs/r/secure_posture_zone.md @@ -8,6 +8,8 @@ description: |- # Resource: sysdig_secure_posture_zone +~> **Deprecated:** `sysdig_secure_posture_zone` is deprecated and will be removed in a future version. Use [`sysdig_secure_zone`](secure_zone) instead. Zone IDs are the same across both APIs, so existing zones can be adopted via `terraform import` without recreation. + Creates a Sysdig Secure Posture Zone. -> **Note:** Sysdig Terraform Provider is under rapid development at this point. If you experience any issue or discrepancy while using it, please make sure you have the latest version. If the issue persists, or you have a Feature Request to support an additional set of resources, please open a [new issue](https://github.com/sysdiglabs/terraform-provider-sysdig/issues/new) in the GitHub repository. diff --git a/website/docs/r/secure_zone.md b/website/docs/r/secure_zone.md index 1a77ee0e..0e511e8b 100644 --- a/website/docs/r/secure_zone.md +++ b/website/docs/r/secure_zone.md @@ -459,6 +459,51 @@ In addition to all arguments above, the following attributes are exported: - `last_modified_by` - (Computed) By whom is last modification made. - `last_updated` - (Computed) Timestamp of last modification of zone. +## Migrating from sysdig_secure_posture_zone + +`sysdig_secure_posture_zone` is deprecated. Zone IDs are the same across both APIs, so the migration does not recreate the zone. + +~> **Note:** `sysdig_secure_posture_zone` supports `policy_ids` to associate posture policies with a zone. `sysdig_secure_zone` does not manage policy assignments. Policy-to-zone associations must be managed separately. + +1. Replace the `sysdig_secure_posture_zone` block with `sysdig_secure_zone` in your configuration, mapping `scopes { scope { ... } }` to top-level `scope` blocks. Note that `scope` is required in `sysdig_secure_zone`: + +```terraform +# Before +resource "sysdig_secure_posture_zone" "example" { + name = "my-zone" + policy_ids = [123, 456] + scopes { + scope { + target_type = "aws" + rules = "account in (\"123456789\")" + } + } +} + +# After +resource "sysdig_secure_zone" "example" { + name = "my-zone" + scope { + target_type = "aws" + rules = "account in (\"123456789\")" + } +} +``` + +2. Remove the old resource from Terraform state: + +``` +$ terraform state rm sysdig_secure_posture_zone.example +``` + +3. Import the existing zone into the new resource: + +``` +$ terraform import sysdig_secure_zone.example 12345 +``` + +4. Run `terraform plan` to verify there are no unexpected changes. + ## How state is managed (drift prevention) When reading a zone from the API, the provider preserves the representation format from your configuration: