Skip to content

Commit 58550b1

Browse files
Fixes issue #24052 related to google_chronicle_reference_list resource (#15036)
1 parent afd5011 commit 58550b1

File tree

3 files changed

+65
-12
lines changed

3 files changed

+65
-12
lines changed

mmv1/products/chronicle/ReferenceList.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ examples:
3434
primary_resource_id: 'example'
3535
vars:
3636
reference_list_id: reference_list_id
37+
data_access_scope_id: scope-id
3738
test_env_vars:
3839
chronicle_id: 'CHRONICLE_ID'
3940

@@ -92,13 +93,11 @@ properties:
9293
required: true
9394
- name: scopeInfo
9495
type: NestedObject
95-
output: true
9696
description: ScopeInfo specifies the scope info of the reference list.
9797
properties:
9898
- name: referenceListScope
9999
type: NestedObject
100100
description: ReferenceListScope specifies the list of scope names of the reference list.
101-
required: true
102101
properties:
103102
- name: scopeNames
104103
type: Array
@@ -108,6 +107,7 @@ properties:
108107
"projects/{project}/locations/{location}/instances/{instance}/dataAccessScopes/{scope_name}".
109108
item_type:
110109
type: String
110+
diff_suppress_func: 'tpgresource.ProjectNumberDiffSuppress'
111111
- name: displayName
112112
type: String
113113
description: Output only. The unique display name of the reference list.
Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1+
resource "google_chronicle_data_access_scope" "test_scope" {
2+
location = "us"
3+
instance = "{{index $.TestEnvVars "chronicle_id"}}"
4+
data_access_scope_id = "{{index $.Vars "data_access_scope_id"}}"
5+
description = "test scope description"
6+
allowed_data_access_labels {
7+
log_type = "GCP_CLOUDAUDIT"
8+
}
9+
}
10+
111
resource "google_chronicle_reference_list" "{{$.PrimaryResourceId}}" {
2-
location = "us"
3-
instance = "{{index $.TestEnvVars "chronicle_id"}}"
4-
reference_list_id = "{{index $.Vars "reference_list_id"}}"
5-
description = "referencelist-description"
6-
entries {
7-
value = "referencelist-entry-value"
8-
}
9-
syntax_type = "REFERENCE_LIST_SYNTAX_TYPE_PLAIN_TEXT_STRING"
12+
location = "us"
13+
instance = "{{index $.TestEnvVars "chronicle_id"}}"
14+
reference_list_id = "{{index $.Vars "reference_list_id"}}"
15+
description = "referencelist-description"
16+
entries {
17+
value = "referencelist-entry-value"
18+
}
19+
syntax_type = "REFERENCE_LIST_SYNTAX_TYPE_PLAIN_TEXT_STRING"
20+
scope_info {
21+
reference_list_scope {
22+
scope_names = [
23+
google_chronicle_data_access_scope.test_scope.name
24+
]
25+
}
26+
}
1027
}

mmv1/third_party/terraform/services/chronicle/resource_chronicle_reference_list_test.go

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ func TestAccChronicleReferenceList_chronicleReferencelistBasicExample_update(t *
1313
t.Parallel()
1414

1515
context := map[string]interface{}{
16-
"chronicle_id": envvar.GetTestChronicleInstanceIdFromEnv(t),
17-
"random_suffix": acctest.RandString(t, 10),
16+
"chronicle_id": envvar.GetTestChronicleInstanceIdFromEnv(t),
17+
"random_suffix": acctest.RandString(t, 10),
18+
"data_access_scope_id": "test-scope-id" + acctest.RandString(t, 5),
19+
"data_access_scope_id_new": "new-test-scope-id" + acctest.RandString(t, 5),
1820
}
1921

2022
acctest.VcrTest(t, resource.TestCase{
@@ -45,6 +47,16 @@ func TestAccChronicleReferenceList_chronicleReferencelistBasicExample_update(t *
4547

4648
func testAccChronicleReferenceList_chronicleReferencelistBasicExample_basic(context map[string]interface{}) string {
4749
return acctest.Nprintf(`
50+
resource "google_chronicle_data_access_scope" "test_scope" {
51+
location = "us"
52+
instance = "%{chronicle_id}"
53+
data_access_scope_id = "%{data_access_scope_id}"
54+
description = "test scope description"
55+
allowed_data_access_labels {
56+
log_type = "GCP_CLOUDAUDIT"
57+
}
58+
}
59+
4860
resource "google_chronicle_reference_list" "example" {
4961
location = "us"
5062
instance = "%{chronicle_id}"
@@ -54,12 +66,29 @@ resource "google_chronicle_reference_list" "example" {
5466
value = "referencelist-entry-value"
5567
}
5668
syntax_type = "REFERENCE_LIST_SYNTAX_TYPE_PLAIN_TEXT_STRING"
69+
scope_info {
70+
reference_list_scope {
71+
scope_names = [
72+
google_chronicle_data_access_scope.test_scope.name
73+
]
74+
}
75+
}
5776
}
5877
`, context)
5978
}
6079

6180
func testAccChronicleReferenceList_chronicleReferencelistBasicExample_update(context map[string]interface{}) string {
6281
return acctest.Nprintf(`
82+
resource "google_chronicle_data_access_scope" "test_scope" {
83+
location = "us"
84+
instance = "%{chronicle_id}"
85+
data_access_scope_id = "%{data_access_scope_id_new}"
86+
description = "test scope description"
87+
allowed_data_access_labels {
88+
log_type = "GITHUB"
89+
}
90+
}
91+
6392
resource "google_chronicle_reference_list" "example" {
6493
location = "us"
6594
instance = "%{chronicle_id}"
@@ -69,6 +98,13 @@ resource "google_chronicle_reference_list" "example" {
6998
value = "referencelist-entry-value-updated"
7099
}
71100
syntax_type = "REFERENCE_LIST_SYNTAX_TYPE_REGEX"
101+
scope_info {
102+
reference_list_scope {
103+
scope_names = [
104+
google_chronicle_data_access_scope.test_scope.name
105+
]
106+
}
107+
}
72108
}
73109
`, context)
74110
}

0 commit comments

Comments
 (0)