Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sysdig/resource_sysdig_secure_accept_posture_risk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions sysdig/resource_sysdig_secure_accept_posture_risk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ func TestAcceptSecurePostureRisk(t *testing.T) {
},
},
Steps: []resource.TestStep{
{
Config: acceptPostureRiskWithoutExpirationDate(),
},
{
Config: acceptPostureRiskResource(),
},
Expand Down Expand Up @@ -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')"
}`
}
Loading