From a4882138a4aa27b7e79dda0619bd706eb6646af1 Mon Sep 17 00:00:00 2001 From: Fede Barcelona Date: Wed, 11 Feb 2026 16:56:53 +0100 Subject: [PATCH] fix(test): use owned resource in posture zone test to prevent flakiness The test used `data.sysdig_secure_posture_policies.all.policies[0].id` to reference a policy, but the data source returns policies in non-deterministic order. Between apply and refresh, re-reading the data source could yield a different policy at index 0, causing "plan was not empty" failures on `policy_ids`. Replace the data source lookup with a test-owned `sysdig_secure_posture_policy` resource so the ID is stable across reads. --- sysdig/resource_sysdig_secure_posture_zone_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sysdig/resource_sysdig_secure_posture_zone_test.go b/sysdig/resource_sysdig_secure_posture_zone_test.go index f504da9d8..94f405b7a 100644 --- a/sysdig/resource_sysdig_secure_posture_zone_test.go +++ b/sysdig/resource_sysdig_secure_posture_zone_test.go @@ -66,10 +66,15 @@ resource "sysdig_secure_posture_zone" "z1" { func securePostureZoneWithPolicies(name string) string { return fmt.Sprintf(` -data "sysdig_secure_posture_policies" "all" {} +resource "sysdig_secure_posture_policy" "test" { + name = "%s-policy" + description = "test policy for posture zone" + is_active = true + type = "Unknown" +} resource "sysdig_secure_posture_zone" "z1" { - name = "%s" - policy_ids = [data.sysdig_secure_posture_policies.all.policies[0].id] -}`, name) + name = "%s" + policy_ids = [sysdig_secure_posture_policy.test.id] +}`, name, name) }