Skip to content

Commit e751521

Browse files
authored
feat: sysdig_secure_policy now supports killing the container (#57)
1 parent dc4e154 commit e751521

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

sysdig/resource_sysdig_secure_policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func resourceSysdigSecurePolicy() *schema.Resource {
9292
"container": {
9393
Type: schema.TypeString,
9494
Optional: true,
95-
ValidateFunc: validation.StringInSlice([]string{"stop", "pause"}, false),
95+
ValidateFunc: validation.StringInSlice([]string{"stop", "pause", "kill"}, false),
9696
},
9797
"capture": {
9898
Type: schema.TypeList,

sysdig/resource_sysdig_secure_policy_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ func TestAccPolicy(t *testing.T) {
4040
{
4141
Config: policiesWithDifferentSeverities(rText()),
4242
},
43+
{
44+
Config: policiesWithKillAction(rText()),
45+
},
4346
},
4447
})
4548
}
@@ -132,3 +135,20 @@ resource "sysdig_secure_policy" "sample_%d" {
132135
}
133136
return
134137
}
138+
139+
func policiesWithKillAction(name string) (res string) {
140+
return fmt.Sprintf(`
141+
resource "sysdig_secure_policy" "sample" {
142+
name = "TERRAFORM TEST 1 %s"
143+
description = "TERRAFORM TEST %s"
144+
enabled = true
145+
severity = 4
146+
scope = "container.id != \"\""
147+
rule_names = ["Terminal shell in container"]
148+
149+
actions {
150+
container = "kill"
151+
}
152+
}
153+
`, name, name)
154+
}

website/docs/r/sysdig_secure_policy.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ resource "sysdig_secure_policy" "write_apt_database" {
6666
The actions block is optional and supports:
6767

6868
* `container` - (Optional) The action applied to container when this Policy is
69-
triggered. Can be *stop* or *pause*.
69+
triggered. Can be *stop*, *pause* or *kill*. If this is not specified,
70+
no action will be applied at the container level.
7071

7172
* `capture` - (Optional) Captures with Sysdig the stream of system calls:
7273
* `seconds_before_event` - (Required) Captures the system calls during the

0 commit comments

Comments
 (0)