Skip to content

Commit 3593fdb

Browse files
author
Ben Lucas
authored
fix policy so that it correctly identifies the default state and does not suggest the resource needs to be updated (#308)
1 parent 5b76ec9 commit 3593fdb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sysdig/resource_sysdig_secure_policy.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,14 @@ func policyToResourceData(policy *secure.Policy, d *schema.ResourceData) {
176176
}}
177177
}
178178
}
179-
_ = d.Set("actions", actions)
179+
180+
currentContainerAction := d.Get("actions.0.container").(string)
181+
currentCaptureAction := d.Get("actions.0.capture").([]interface{})
182+
// If the policy retrieved from service has no actions and the current state is default values,
183+
// then do not set the "actions" key as it may cause terraform to think there has been a state change
184+
if len(policy.Actions) > 0 || currentContainerAction != "" || len(currentCaptureAction) > 0 {
185+
_ = d.Set("actions", actions)
186+
}
180187

181188
_ = d.Set("notification_channels", policy.NotificationChannelIds)
182189

0 commit comments

Comments
 (0)