Skip to content

Commit f9bdac5

Browse files
add fix
1 parent e451672 commit f9bdac5

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

sysdig/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const (
2828
SchemaIsSystemKey = "is_system"
2929
SchemaUsernameKey = "username"
3030
SchemaAcceptPeriodKey = "accept_period"
31+
SchemaEndTimeKey = "end_time"
3132
SchemaReasonKey = "reason"
3233
SchemaVersionKey = "version"
3334
SchemaLinkKey = "link"

sysdig/resource_sysdig_secure_accept_posture_risk.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func resourceSysdigSecureAcceptPostureRisk() *schema.Resource {
6161
},
6262
SchemaExpiresAtKey: {
6363
Type: schema.TypeString,
64-
Optional: true,
64+
Computed: true,
6565
},
6666
SchemaIsExpiredKey: {
6767
Type: schema.TypeBool,
@@ -87,6 +87,11 @@ func resourceSysdigSecureAcceptPostureRisk() *schema.Resource {
8787
Type: schema.TypeString,
8888
Computed: true,
8989
},
90+
SchemaEndTimeKey: {
91+
Type: schema.TypeString,
92+
Optional: true,
93+
Default: "",
94+
},
9095
},
9196
}
9297
}
@@ -106,26 +111,26 @@ func resourceSysdigSecureAcceptPostureControlCreate(ctx context.Context, d *sche
106111
Filter: d.Get(SchemaFilterKey).(string),
107112
Reason: d.Get(SchemaReasonKey).(string),
108113
}
109-
var expiresAt int64
114+
var endTime int64
110115
expiresIn := d.Get(SchemaExpiresInKey).(string)
111116
if expiresIn == "7 Days" {
112-
expiresAt = time.Now().AddDate(0, 0, 7).UTC().UnixMilli()
117+
endTime = time.Now().AddDate(0, 0, 7).UTC().UnixMilli()
113118
} else if expiresIn == "30 Days" {
114-
expiresAt = time.Now().AddDate(0, 0, 30).UTC().UnixMilli()
119+
endTime = time.Now().AddDate(0, 0, 30).UTC().UnixMilli()
115120
} else if expiresIn == "60 Days" {
116-
expiresAt = time.Now().AddDate(0, 0, 60).UTC().UnixMilli()
121+
endTime = time.Now().AddDate(0, 0, 60).UTC().UnixMilli()
117122
} else if expiresIn == "90 Days" {
118-
expiresAt = time.Now().AddDate(0, 0, 90).UTC().UnixMilli()
123+
endTime = time.Now().AddDate(0, 0, 90).UTC().UnixMilli()
119124
} else if expiresIn == "Never" {
120-
expiresAt = 0
125+
endTime = 0
121126
} else {
122-
t := d.Get(SchemaExpiresAtKey).(string)
123-
expiresAt, _ = strconv.ParseInt(t, 10, 64)
127+
t := d.Get(SchemaEndTimeKey).(string)
128+
endTime, _ = strconv.ParseInt(t, 10, 64)
124129
}
125-
if expiresAt <= time.Now().UTC().UnixMilli() {
130+
if endTime <= time.Now().UTC().UnixMilli() {
126131
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"))
127132
}
128-
req.ExpiresAt = strconv.FormatInt(expiresAt, 10)
133+
req.ExpiresAt = strconv.FormatInt(endTime, 10)
129134
acceptance, errStatus, err := client.SaveAcceptPostureRisk(ctx, req)
130135
if err != nil {
131136
return diag.Errorf("Error creating accept risk. error status: %s err: %s", errStatus, err)
@@ -165,7 +170,7 @@ func resourceSysdigSecureAcceptPostureControlUpdate(ctx context.Context, d *sche
165170
millis = 0
166171
} else {
167172
req.Acceptance.AcceptPeriod = "Custom"
168-
t := d.Get(SchemaExpiresAtKey).(string)
173+
t := d.Get(SchemaEndTimeKey).(string)
169174
millis, err = strconv.ParseInt(t, 10, 64)
170175
if millis <= time.Now().UTC().UnixMilli() {
171176
return diag.Errorf("Error updating accept risk. ID: %s, error status: %s err: %s", req.AcceptanceID, "ExpiresAt must be in the future", err)

website/docs/r/secure_posture_accept_risk.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ resource "sysdig_secure_posture_accept_risk" "scheduler_set_to_loopback_bind_add
3737
control_name = "Scheduler - Set to Loopback bind-address"
3838
reason = "Custom"
3939
expires_in = "Custom"
40-
expires_at = "1730293523000"
40+
end_time = "1730293523000"
4141
zone_name = "Entire Infrastructure"
4242
}
4343
```
@@ -90,7 +90,9 @@ resource "sysdig_secure_posture_accept_risk" "scheduler_set_to_loopback_bind_add
9090
- `90 Days`
9191
- `Custom`
9292
- `Never`
93-
- `expires_at` - (Optional) This timestamp indicates when the acceptance expires, formatted in UTC time (milliseconds since epoch). If you choose expires_in=Custom, you must provide expires_at, which specifies the expiration date in milliseconds.
93+
- `expires_at` - (Computed) This timestamp indicates when the acceptance expires, formatted in UTC time (milliseconds since epoch).
94+
- `end_time` - (Optional) This timestamp indicates the custom time, when the acceptance expires, formatted in UTC time (milliseconds since epoch).
95+
If you choose expires_in=Custom, you should provide future end_time, which specifies the expiration date in milliseconds.
9496
- `is_expired` - (Computed) Indicates whether the acceptance is expired.
9597
- `acceptance_date` - (Computed) The date when the risk was accepted.
9698
- `username` - (Computed) The username of the user who accepted the risk.
@@ -107,7 +109,7 @@ In addition to all arguments above, the following attributes are exported:
107109

108110
## Import
109111

110-
Posture custom control can be imported using the ID, e.g.
112+
Posture accept risk can be imported using the ID, e.g.
111113

112114
```
113115
$ terraform import sysdig_secure_posture_accept_risk.example c 12345

0 commit comments

Comments
 (0)