Skip to content

Commit 5460b28

Browse files
vijaykanthmDawid212
authored andcommitted
Update resource SCC Mute Config with expiry time field (GoogleCloudPlatform#12979)
1 parent 468a729 commit 5460b28

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

mmv1/products/securitycenter/MuteConfig.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,20 @@ properties:
102102
field is set by the server and will be ignored if provided on
103103
config creation or update.
104104
output: true
105+
- name: 'type'
106+
type: Enum
107+
description: |
108+
The type of the mute config, which determines what type of mute state the config affects.
109+
default_value: "DYNAMIC"
110+
enum_values:
111+
- 'MUTE_CONFIG_TYPE_UNSPECIFIED'
112+
- 'STATIC'
113+
- 'DYNAMIC'
114+
- name: 'expiryTime'
115+
type: String
116+
description: |
117+
Optional. The expiry of the mute config. Only applicable for dynamic configs.
118+
If the expiry is set, when the config expires, it is removed from all findings.
119+
120+
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to
121+
nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

mmv1/templates/terraform/examples/scc_mute_config.tf.tmpl

+2
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ resource "google_scc_mute_config" "{{$.PrimaryResourceId}}" {
33
parent = "organizations/{{index $.TestEnvVars "org_id"}}"
44
filter = "category: \"OS_VULNERABILITY\""
55
description = "My Mute Config"
6+
type = "DYNAMIC"
7+
expiry_time = "2215-02-03T15:01:23Z"
68
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package securitycenter_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
7+
"github.com/hashicorp/terraform-provider-google/google/acctest"
8+
"github.com/hashicorp/terraform-provider-google/google/envvar"
9+
)
10+
11+
func TestAccSecurityCenterMuteConfig(t *testing.T) {
12+
t.Parallel()
13+
14+
context := map[string]interface{}{
15+
"org_id": envvar.GetTestOrgFromEnv(t),
16+
"random_suffix": acctest.RandString(t, 10),
17+
}
18+
19+
acctest.VcrTest(t, resource.TestCase{
20+
PreCheck: func() { acctest.AccTestPreCheck(t) },
21+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
22+
ExternalProviders: map[string]resource.ExternalProvider{
23+
"random": {},
24+
"time": {},
25+
},
26+
Steps: []resource.TestStep{
27+
{
28+
Config: testAccSecurityCenterMuteConfig_basic(context),
29+
},
30+
{
31+
ResourceName: "google_scc_mute_config.default",
32+
ImportState: true,
33+
ImportStateVerify: true,
34+
ImportStateVerifyIgnore: []string{
35+
"mute_config_id",
36+
},
37+
},
38+
{
39+
Config: testAccSecurityCenterMuteConfig_update(context),
40+
},
41+
{
42+
ResourceName: "google_scc_mute_config.default",
43+
ImportState: true,
44+
ImportStateVerify: true,
45+
ImportStateVerifyIgnore: []string{
46+
"mute_config_id",
47+
},
48+
},
49+
},
50+
})
51+
}
52+
53+
func testAccSecurityCenterMuteConfig_basic(context map[string]interface{}) string {
54+
return acctest.Nprintf(`
55+
56+
resource "google_scc_mute_config" "default" {
57+
mute_config_id = "tf-test-mute-config-%{random_suffix}"
58+
parent = "organizations/%{org_id}"
59+
filter = "category: \"OS_VULNERABILITY\""
60+
description = "A Test Mute Config"
61+
type = "DYNAMIC"
62+
expiry_time = "2215-02-03T15:01:23Z"
63+
}
64+
`, context)
65+
}
66+
67+
func testAccSecurityCenterMuteConfig_update(context map[string]interface{}) string {
68+
return acctest.Nprintf(`
69+
70+
resource "google_scc_mute_config" "default" {
71+
mute_config_id = "tf-test-mute-config-%{random_suffix}"
72+
parent = "organizations/%{org_id}"
73+
filter = "category: \"OS_VULNERABILITY\""
74+
description = "An Updated Test Mute Config"
75+
type = "DYNAMIC"
76+
expiry_time = "2215-02-03T15:01:23Z"
77+
}
78+
`, context)
79+
}

0 commit comments

Comments
 (0)