Skip to content

Commit b702df5

Browse files
author
Harshita
committed
Add DataTable Resource
1 parent 1952662 commit b702df5

6 files changed

Lines changed: 468 additions & 1 deletion

File tree

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
# Copyright 2026 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: DataTable
16+
description: Represents a Chronicle Data Table, a multicolumn structure used to ingest your own data into Google SecOps.
17+
18+
base_url: projects/{{project}}/locations/{{location}}/instances/{{instance}}/dataTables
19+
create_url: projects/{{project}}/locations/{{location}}/instances/{{instance}}/dataTables?dataTableId={{data_table_id}}
20+
self_link: projects/{{project}}/locations/{{location}}/instances/{{instance}}/dataTables/{{data_table_id}}
21+
id_format: projects/{{project}}/locations/{{location}}/instances/{{instance}}/dataTables/{{data_table_id}}
22+
import_format:
23+
- projects/{{project}}/locations/{{location}}/instances/{{instance}}/dataTables/{{data_table_id}}
24+
25+
update_verb: PATCH
26+
update_mask: true
27+
min_version: 'beta'
28+
references:
29+
guides:
30+
'Google SecOps Guides': 'https://cloud.google.com/chronicle/docs/secops/secops-overview'
31+
api: 'https://cloud.google.com/chronicle/docs/reference/rest/v1beta/projects.locations.instances.dataTables'
32+
examples:
33+
- name: 'chronicle_data_table_basic'
34+
config_path: 'templates/terraform/examples/chronicle_data_table_basic.tf.tmpl'
35+
primary_resource_id: 'example'
36+
min_version: 'beta'
37+
test_env_vars:
38+
chronicle_id: 'CHRONICLE_ID'
39+
vars:
40+
data_table_id: 'terraform_test'
41+
- name: 'chronicle_data_table_with_optional_fields'
42+
config_path: 'templates/terraform/examples/chronicle_data_table_with_optional_fields.tf.tmpl'
43+
primary_resource_id: 'example_dt'
44+
min_version: 'beta'
45+
test_env_vars:
46+
chronicle_id: 'CHRONICLE_ID'
47+
vars:
48+
data_table_id: 'tf_test_full'
49+
autogen_status: RGF0YVRhYmxl
50+
51+
custom_code:
52+
pre_delete: 'templates/terraform/pre_delete/chronicle_data_table.go.tmpl'
53+
54+
virtual_fields:
55+
- name: 'deletion_policy'
56+
description: |
57+
The policy governing the deletion of the data table.
58+
If set to `FORCE`, allows the deletion of the data table even if it contains rows.
59+
If set to `DEFAULT`,or if the field is omitted, the data table must be empty before it can be deleted.
60+
Possible values: DEFAULT, FORCE
61+
type: String
62+
default_value: "DEFAULT"
63+
64+
parameters:
65+
- name: location
66+
type: String
67+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
68+
immutable: true
69+
url_param_only: true
70+
required: true
71+
- name: instance
72+
type: String
73+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
74+
immutable: true
75+
url_param_only: true
76+
required: true
77+
- name: dataTableId
78+
type: String
79+
description: |-
80+
The ID to use for the data table. This is also the display name for
81+
the data table. It must satisfy the following requirements:
82+
- Starts with letter.
83+
- Contains only letters, numbers and underscore.
84+
- Must be unique and has length < 256.
85+
immutable: true
86+
url_param_only: true
87+
required: true
88+
properties:
89+
- name: approximateRowCount
90+
type: Integer
91+
description: The count of rows in the data table.
92+
output: true
93+
- name: columnInfo
94+
type: Array
95+
description: Details of all the columns in the table
96+
immutable: true
97+
item_type:
98+
type: NestedObject
99+
properties:
100+
- name: columnIndex
101+
type: Integer
102+
description: Column Index. 0,1,2...
103+
required: true
104+
immutable: true
105+
- name: columnType
106+
type: Enum
107+
description: |-
108+
Column type can be STRING, CIDR (Ex- 10.1.1.0/24), REGEX
109+
Possible values:
110+
STRING
111+
REGEX
112+
CIDR
113+
NUMBER
114+
enum_values:
115+
- STRING
116+
- REGEX
117+
- CIDR
118+
- NUMBER
119+
immutable: true
120+
- name: keyColumn
121+
type: Boolean
122+
description: |-
123+
Whether to include this column in the calculation of the row ID.
124+
If no columns have key_column = true, all columns will be included in the
125+
calculation of the row ID.
126+
immutable: true
127+
- name: mappedColumnPath
128+
type: String
129+
description: Entity proto field path that the column is mapped to
130+
immutable: true
131+
- name: originalColumn
132+
type: String
133+
description: |-
134+
Original column name of the Data Table (present in the CSV header in case
135+
of creation of data tables using file uploads). It must satisfy the
136+
following requirements:
137+
- Starts with letter.
138+
- Contains only letters, numbers and underscore.
139+
- Must be unique and has length < 256
140+
required: true
141+
immutable: true
142+
- name: repeatedValues
143+
type: Boolean
144+
description: Whether the column is a repeated values column.
145+
immutable: true
146+
- name: createTime
147+
type: String
148+
description: Table create time
149+
output: true
150+
- name: dataTableUuid
151+
type: String
152+
description: Data table unique id
153+
output: true
154+
- name: description
155+
type: String
156+
description: A user-provided description of the data table.
157+
required: true
158+
- name: displayName
159+
type: String
160+
description: The unique display name of the data table.
161+
output: true
162+
- name: name
163+
type: String
164+
description: |-
165+
Identifier. The resource name of the data table
166+
Format:
167+
"{project}/locations/{region}/instances/{instance}/dataTables/{data_table}"
168+
output: true
169+
- name: rowTimeToLive
170+
type: String
171+
description: User-provided TTL of the data table.
172+
- name: rowTimeToLiveUpdateTime
173+
type: String
174+
description: Last update time of the TTL of the data table.
175+
output: true
176+
- name: ruleAssociationsCount
177+
type: Integer
178+
description: The count of rules using the data table.
179+
output: true
180+
- name: rules
181+
type: Array
182+
description: |-
183+
The resource names for the associated Rules that use this
184+
data table. Format:
185+
projects/{project}/locations/{location}/instances/{instance}/rules/{rule}.
186+
{rule} here refers to the rule id.
187+
output: true
188+
item_type:
189+
type: String
190+
- name: scopeInfo
191+
type: NestedObject
192+
description: DataTableScopeInfo specifies the scope info of the data table.
193+
properties:
194+
- name: dataAccessScopes
195+
type: Array
196+
description: |-
197+
Contains the list of scope names of the data table. If the list is empty,
198+
the data table is treated as unscoped. The scope names should be
199+
full resource names and should be of the format:
200+
"projects/{project}/locations/{location}/instances/{instance}/dataAccessScopes/{scope_name}"
201+
required: true
202+
item_type:
203+
type: String
204+
- name: updateSource
205+
type: Enum
206+
description: |2-
207+
Possible values:
208+
USER
209+
RULE
210+
SEARCH
211+
enum_values:
212+
- USER
213+
- RULE
214+
- SEARCH
215+
output: true
216+
- name: updateTime
217+
type: String
218+
description: Table update time
219+
output: true

mmv1/products/chronicle/product.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 Google Inc.
1+
# Copyright 2026 Google Inc.
22
# Licensed under the Apache License, Version 2.0 (the "License");
33
# you may not use this file except in compliance with the License.
44
# You may obtain a copy of the License at
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
resource "google_chronicle_data_table" "example" {
2+
provider = google-beta
3+
location = "us"
4+
instance = "{{index $.TestEnvVars "chronicle_id"}}"
5+
data_table_id = "{{index $.Vars "data_table_id"}}"
6+
description = "sample desc"
7+
column_info {
8+
column_index = 0
9+
original_column = "username"
10+
column_type = "STRING"
11+
}
12+
column_info {
13+
column_index = 1
14+
original_column = "ip_address"
15+
column_type = "CIDR"
16+
}
17+
}
18+
19+
output "data_table_name" {
20+
description = "The resource name of the data table."
21+
value = google_chronicle_data_table.example.name
22+
}
23+
24+
output "data_table_id" {
25+
description = "The user-provided ID of the data table."
26+
value = google_chronicle_data_table.example.data_table_id
27+
}
28+
29+
output "data_table_uuid" {
30+
description = "The system-generated UUID of the data table."
31+
value = google_chronicle_data_table.example.data_table_uuid
32+
}
33+
34+
output "data_table_description" {
35+
description = "The description of the data table."
36+
value = google_chronicle_data_table.example.description
37+
}
38+
39+
output "data_table_create_time" {
40+
description = "The creation time of the data table."
41+
value = google_chronicle_data_table.example.create_time
42+
}
43+
44+
output "data_table_ttl" {
45+
description = "The row time to live for the data table."
46+
value = google_chronicle_data_table.example.row_time_to_live
47+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
resource "google_chronicle_data_access_scope" "test_scope_allow_everyone" {
2+
provider = google-beta
3+
location = "us"
4+
instance = "{{index $.TestEnvVars "chronicle_id"}}"
5+
data_access_scope_id = "tf-scope-003"
6+
description = "scope-description"
7+
allowed_data_access_labels {
8+
log_type = "GCP_CLOUDAUDIT"
9+
}
10+
}
11+
12+
resource "google_chronicle_data_table" "example_dt" {
13+
provider = google-beta
14+
project = "terraform-dev-harshiita"
15+
location = "us"
16+
instance = "{{index $.TestEnvVars "chronicle_id"}}"
17+
data_table_id = "{{index $.Vars "data_table_id"}}"
18+
description = "Comprehensive test table with all teh fields"
19+
row_time_to_live = "48h"
20+
21+
column_info {
22+
column_index = 0
23+
original_column = "username"
24+
key_column = true
25+
mapped_column_path = "entity.user.userid"
26+
repeated_values = false
27+
}
28+
column_info {
29+
column_index = 1
30+
original_column = "ip_address"
31+
column_type = "CIDR"
32+
key_column = false
33+
repeated_values = false
34+
}
35+
36+
scope_info {
37+
data_access_scopes = [google_chronicle_data_access_scope.test_scope_allow_everyone.name]
38+
}
39+
depends_on = [google_chronicle_data_access_scope.test_scope_allow_everyone]
40+
}
41+
42+
output "data_table_name" {
43+
description = "The resource name of the created data table."
44+
value = google_chronicle_data_table.example_dt.name
45+
}
46+
47+
output "data_table_id" {
48+
description = "The ID of the created data table."
49+
value = google_chronicle_data_table.example_dt.id
50+
}
51+
52+
output "data_table_create_time" {
53+
description = "The creation time of the data table."
54+
value = google_chronicle_data_table.example_dt.create_time
55+
}
56+
57+
output "data_table_column_info" {
58+
description = "The column info of the data table."
59+
value = google_chronicle_data_table.example_dt.column_info
60+
}
61+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Forcefully delete data table even if there are any rows associated.
2+
if deletionPolicy := d.Get("deletion_policy"); deletionPolicy == "FORCE" {
3+
url = url + "?force=true"
4+
}

0 commit comments

Comments
 (0)