diff --git a/sysdig/resource_sysdig_secure_accept_posture_risk.go b/sysdig/resource_sysdig_secure_accept_posture_risk.go index 5089185a6..bd255c49a 100644 --- a/sysdig/resource_sysdig_secure_accept_posture_risk.go +++ b/sysdig/resource_sysdig_secure_accept_posture_risk.go @@ -127,7 +127,7 @@ func resourceSysdigSecureAcceptPostureControlCreate(ctx context.Context, d *sche t := d.Get(SchemaEndTimeKey).(string) endTime, _ = strconv.ParseInt(t, 10, 64) } - if endTime <= time.Now().UTC().UnixMilli() { + if endTime > 0 && endTime <= time.Now().UTC().UnixMilli() { return diag.Errorf("Error creating accept risk. error status: %s err: %s", "ExpiresAt must be in the future", fmt.Errorf("ExpiresAt must be in the future")) } req.ExpiresAt = strconv.FormatInt(endTime, 10) diff --git a/sysdig/resource_sysdig_secure_accept_posture_risk_test.go b/sysdig/resource_sysdig_secure_accept_posture_risk_test.go index a016bec7d..826750a05 100644 --- a/sysdig/resource_sysdig_secure_accept_posture_risk_test.go +++ b/sysdig/resource_sysdig_secure_accept_posture_risk_test.go @@ -19,6 +19,9 @@ func TestAcceptSecurePostureRisk(t *testing.T) { }, }, Steps: []resource.TestStep{ + { + Config: acceptPostureRiskWithoutExpirationDate(), + }, { Config: acceptPostureRiskResource(), }, @@ -50,3 +53,14 @@ resource "sysdig_secure_posture_accept_risk" "accept_resource" { filter = "name in ('system:controller:daemon-set-s') and kind in ('ClusterRole')" }` } + +func acceptPostureRiskWithoutExpirationDate() string { + return ` +resource "sysdig_secure_posture_accept_risk" "accept_resource" { + description = "test accept posture risk resource" + control_name = "ServiceAccounts with cluster access" + reason = "Risk Transferred" + expires_in = "Never" + filter = "name in ('system:controller:daemon-set-s') and kind in ('ClusterRole')" +}` +}