Skip to content

Commit c1195cb

Browse files
ankitgoyal0301anoopkverma-google
authored andcommitted
Add google_chronicle_reference_list resource to chronicle (GoogleCloudPlatform#12717)
1 parent a5d58c2 commit c1195cb

File tree

3 files changed

+231
-0
lines changed

3 files changed

+231
-0
lines changed
+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Copyright 2025 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: ReferenceList
16+
description: Reference lists are user-defined lists of values which users can use in multiple Rules.
17+
min_version: 'beta'
18+
references:
19+
guides:
20+
'Google SecOps Guides': 'https://cloud.google.com/chronicle/docs/secops/secops-overview'
21+
api: 'https://cloud.google.com/chronicle/docs/reference/rest/v1alpha/projects.locations.instances.referenceLists'
22+
base_url: projects/{{project}}/locations/{{location}}/instances/{{instance}}/referenceLists
23+
self_link: projects/{{project}}/locations/{{location}}/instances/{{instance}}/referenceLists/{{reference_list_id}}
24+
create_url: projects/{{project}}/locations/{{location}}/instances/{{instance}}/referenceLists?referenceListId={{reference_list_id}}
25+
id_format: projects/{{project}}/locations/{{location}}/instances/{{instance}}/referenceLists/{{reference_list_id}}
26+
import_format:
27+
- projects/{{project}}/locations/{{location}}/instances/{{instance}}/referenceLists/{{reference_list_id}}
28+
update_verb: PATCH
29+
update_mask: true
30+
exclude_delete: true
31+
32+
examples:
33+
- name: 'chronicle_referencelist_basic'
34+
primary_resource_id: 'example'
35+
min_version: 'beta'
36+
vars:
37+
reference_list_id: reference_list_id
38+
test_env_vars:
39+
chronicle_id: 'CHRONICLE_ID'
40+
41+
parameters:
42+
- name: location
43+
type: String
44+
description: The location of the resource. This is the geographical region where the Chronicle instance resides, such as "us" or "europe-west2".
45+
immutable: true
46+
url_param_only: true
47+
required: true
48+
- name: instance
49+
type: String
50+
description: The unique identifier for the Chronicle instance, which is the same as the customer ID.
51+
immutable: true
52+
url_param_only: true
53+
required: true
54+
- name: referenceListId
55+
type: String
56+
description: |-
57+
Required. The ID to use for the reference list. This is also the display name for
58+
the reference list. It must satisfy the following requirements:
59+
- Starts with letter.
60+
- Contains only letters, numbers and underscore.
61+
- Has length < 256.
62+
- Must be unique.
63+
immutable: true
64+
url_param_only: true
65+
required: true
66+
properties:
67+
- name: name
68+
type: String
69+
description: |-
70+
Output only. The resource name of the reference list.
71+
Format:
72+
projects/{project}/locations/{location}/instances/{instance}/referenceLists/{reference_list}
73+
output: true
74+
- name: description
75+
type: String
76+
description: Required. A user-provided description of the reference list.
77+
required: true
78+
- name: entries
79+
type: Array
80+
description: |-
81+
Required. The entries of the reference list.
82+
When listed, they are returned in the order that was specified at creation
83+
or update. The combined size of the values of the reference list may not
84+
exceed 6MB.
85+
This is returned only when the view is REFERENCE_LIST_VIEW_FULL.
86+
required: true
87+
item_type:
88+
type: NestedObject
89+
properties:
90+
- name: value
91+
type: String
92+
description: Required. The value of the entry. Maximum length is 512 characters.
93+
required: true
94+
- name: scopeInfo
95+
type: NestedObject
96+
output: true
97+
description: ScopeInfo specifies the scope info of the reference list.
98+
properties:
99+
- name: referenceListScope
100+
type: NestedObject
101+
description: ReferenceListScope specifies the list of scope names of the reference list.
102+
required: true
103+
properties:
104+
- name: scopeNames
105+
type: Array
106+
description: |-
107+
Optional. The list of scope names of the reference list. The scope names should be
108+
full resource names and should be of the format:
109+
"projects/{project}/locations/{location}/instances/{instance}/dataAccessScopes/{scope_name}".
110+
item_type:
111+
type: String
112+
- name: displayName
113+
type: String
114+
description: Output only. The unique display name of the reference list.
115+
output: true
116+
- name: revisionCreateTime
117+
type: String
118+
description: Output only. The timestamp when the reference list was last updated.
119+
output: true
120+
- name: rules
121+
type: Array
122+
description: |-
123+
Output only. The resource names for the associated self-authored Rules that use this
124+
reference list.
125+
This is returned only when the view is REFERENCE_LIST_VIEW_FULL.
126+
output: true
127+
item_type:
128+
type: String
129+
- name: syntaxType
130+
type: String
131+
description: |2-
132+
133+
Possible values:
134+
REFERENCE_LIST_SYNTAX_TYPE_PLAIN_TEXT_STRING
135+
REFERENCE_LIST_SYNTAX_TYPE_REGEX
136+
REFERENCE_LIST_SYNTAX_TYPE_CIDR
137+
required: true
138+
- name: ruleAssociationsCount
139+
type: Integer
140+
description: Output only. The count of self-authored rules using the reference list.
141+
output: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resource "google_chronicle_reference_list" "{{$.PrimaryResourceId}}" {
2+
provider = "google-beta"
3+
location = "us"
4+
instance = "{{index $.TestEnvVars "chronicle_id"}}"
5+
reference_list_id = "{{index $.Vars "reference_list_id"}}"
6+
description = "referencelist-description"
7+
entries {
8+
value = "referencelist-entry-value"
9+
}
10+
syntax_type = "REFERENCE_LIST_SYNTAX_TYPE_PLAIN_TEXT_STRING"
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package chronicle_test
2+
3+
{{- if ne $.TargetVersionName "ga" }}
4+
5+
import (
6+
"testing"
7+
8+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
9+
10+
"github.com/hashicorp/terraform-provider-google/google/acctest"
11+
"github.com/hashicorp/terraform-provider-google/google/envvar"
12+
)
13+
14+
func TestAccChronicleReferenceList_chronicleReferencelistBasicExample_update(t *testing.T) {
15+
t.Parallel()
16+
17+
context := map[string]interface{}{
18+
"chronicle_id": envvar.GetTestChronicleInstanceIdFromEnv(t),
19+
"random_suffix": acctest.RandString(t, 10),
20+
}
21+
22+
acctest.VcrTest(t, resource.TestCase{
23+
PreCheck: func() { acctest.AccTestPreCheck(t) },
24+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
25+
Steps: []resource.TestStep{
26+
{
27+
Config: testAccChronicleReferenceList_chronicleReferencelistBasicExample_basic(context),
28+
},
29+
{
30+
ResourceName: "google_chronicle_reference_list.example",
31+
ImportState: true,
32+
ImportStateVerify: true,
33+
ImportStateVerifyIgnore: []string{"instance", "location", "reference_list_id"},
34+
},
35+
{
36+
Config: testAccChronicleReferenceList_chronicleReferencelistBasicExample_update(context),
37+
},
38+
{
39+
ResourceName: "google_chronicle_reference_list.example",
40+
ImportState: true,
41+
ImportStateVerify: true,
42+
ImportStateVerifyIgnore: []string{"instance", "location", "reference_list_id"},
43+
},
44+
},
45+
})
46+
}
47+
48+
func testAccChronicleReferenceList_chronicleReferencelistBasicExample_basic(context map[string]interface{}) string {
49+
return acctest.Nprintf(`
50+
resource "google_chronicle_reference_list" "example" {
51+
provider = "google-beta"
52+
location = "us"
53+
instance = "%{chronicle_id}"
54+
reference_list_id = "tf_test_reference_list_id%{random_suffix}"
55+
description = "referencelist-description"
56+
entries {
57+
value = "referencelist-entry-value"
58+
}
59+
syntax_type = "REFERENCE_LIST_SYNTAX_TYPE_PLAIN_TEXT_STRING"
60+
}
61+
`, context)
62+
}
63+
64+
func testAccChronicleReferenceList_chronicleReferencelistBasicExample_update(context map[string]interface{}) string {
65+
return acctest.Nprintf(`
66+
resource "google_chronicle_reference_list" "example" {
67+
provider = "google-beta"
68+
location = "us"
69+
instance = "%{chronicle_id}"
70+
reference_list_id = "tf_test_reference_list_id%{random_suffix}"
71+
description = "referencelist-description-updated"
72+
entries {
73+
value = "referencelist-entry-value-updated"
74+
}
75+
syntax_type = "REFERENCE_LIST_SYNTAX_TYPE_REGEX"
76+
}
77+
`, context)
78+
}
79+
{{- end }}

0 commit comments

Comments
 (0)