Skip to content

Commit c3f8da8

Browse files
committed
2 parents 1f2f81c + b2a22b0 commit c3f8da8

12 files changed

Lines changed: 505 additions & 0 deletions

File tree

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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: 'Config'
16+
api_variant_patterns:
17+
- 'projects/{project}/locations/{location}/config'
18+
- 'folders/{folder}/locations/{location}/config'
19+
- 'organizations/{organization}/locations/{location}/config'
20+
description: |
21+
Configuration for Data Lineage.
22+
23+
Defines configuration options for Lineage customers to control behavior of
24+
lineage systems.
25+
references:
26+
guides:
27+
'Official Documentation': 'https://docs.cloud.google.com/dataplex/docs/about-data-lineage#control-lineage-ingestion'
28+
api: 'https://docs.cloud.google.com/dataplex/docs/reference/data-lineage/rest/v1/folders.locations.config'
29+
docs:
30+
id_format: '{{parent}}/locations/{{location}}/config'
31+
base_url: '{{parent}}/locations/{{location}}/config'
32+
self_link: '{{parent}}/locations/{{location}}/config'
33+
create_url: '{{parent}}/locations/{{location}}/config'
34+
create_verb: 'PATCH'
35+
update_verb: 'PATCH'
36+
delete_verb: 'PATCH'
37+
update_mask: false
38+
exclude_delete: false
39+
import_format:
40+
- '{{%parent}}/locations/{{location}}/config'
41+
42+
autogen_async: false
43+
custom_code:
44+
test_check_destroy: 'templates/terraform/custom_check_destroy/datalineage_config.go.tmpl'
45+
46+
examples:
47+
- name: 'data_lineage_config_project'
48+
primary_resource_id: 'default'
49+
test_env_vars:
50+
project: 'PROJECT_NAME'
51+
- name: 'data_lineage_config_folder'
52+
primary_resource_id: 'default'
53+
vars:
54+
folder_name: 'config-f'
55+
test_env_vars:
56+
organization: 'ORG_ID'
57+
service_account: 'SERVICE_ACCT'
58+
external_providers: ["time"]
59+
- name: 'data_lineage_config_organization'
60+
primary_resource_id: 'default'
61+
test_env_vars:
62+
organization: 'ORG_ID'
63+
64+
parameters:
65+
- name: 'parent'
66+
type: String
67+
description: |
68+
Parent scope for the config.
69+
Format: projects/{project-id|project-number} or folders/{folder-number} or organizations/{organization-number}.
70+
url_param_only: true
71+
required: true
72+
immutable: true
73+
- name: 'location'
74+
type: String
75+
description: |
76+
The region of the data lineage configuration for integration.
77+
url_param_only: true
78+
required: true
79+
immutable: true
80+
81+
properties:
82+
- name: 'name'
83+
type: String
84+
description: |
85+
Identifier. The resource name of the config.
86+
Format: organizations/{organization_id}/locations/{location}/config,
87+
folders/{folder_id}/locations/{location}/config,
88+
projects/{project_id}/locations/{location}/config,
89+
or projects/{project_number}/locations/{location}/config.
90+
output: true
91+
- name: 'etag'
92+
type: Fingerprint
93+
description: |
94+
Used for optimistic concurrency control when patching config.
95+
output: true
96+
- name: 'ingestion'
97+
type: NestedObject
98+
description: |
99+
Defines how Lineage should be ingested for this resource.
100+
required: true
101+
properties:
102+
- name: 'rule'
103+
type: Array
104+
description: |
105+
List of ingestion rules for Data Lineage ingestion.
106+
api_name: rules
107+
required: true
108+
min_size: 1
109+
item_type:
110+
type: NestedObject
111+
properties:
112+
- name: 'integrationSelector'
113+
type: NestedObject
114+
description: |
115+
Selects which integration this rule applies to.
116+
required: true
117+
properties:
118+
- name: 'integration'
119+
type: Enum
120+
description: |
121+
Integration to which the rule applies.
122+
required: true
123+
enum_values:
124+
- 'DATAPROC'
125+
- 'LOOKER_CORE'
126+
- name: 'lineageEnablement'
127+
type: NestedObject
128+
description: |
129+
Configures lineage ingestion enablement for this scope.
130+
required: true
131+
properties:
132+
- name: 'enabled'
133+
type: Boolean
134+
description: |
135+
Whether ingestion of lineage should be enabled.
136+
required: true
137+
send_empty_value: true
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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: DataLineage
16+
display_name: Data Lineage
17+
versions:
18+
- name: 'ga'
19+
base_url: 'https://datalineage.googleapis.com/v1/'
20+
- name: 'beta'
21+
base_url: 'https://datalineage.googleapis.com/v1/'
22+
scopes:
23+
- 'https://www.googleapis.com/auth/cloud-platform'
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
config := acctest.GoogleProviderConfig(t)
2+
3+
url, err := tpgresource.ReplaceVarsForTest(config, rs, "{{"{{"}}DataLineageBasePath{{"}}"}}{{"{{"}}parent{{"}}"}}/locations/{{"{{"}}location{{"}}"}}/config")
4+
if err != nil {
5+
return err
6+
}
7+
8+
billingProject := ""
9+
10+
if config.BillingProject != "" {
11+
billingProject = config.BillingProject
12+
}
13+
14+
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
15+
Config: config,
16+
Method: "GET",
17+
Project: billingProject,
18+
RawURL: url,
19+
UserAgent: config.UserAgent,
20+
})
21+
if err != nil {
22+
return nil
23+
}
24+
25+
if ingestion, ok := res["ingestion"]; ok {
26+
if ingestionMap, ok := ingestion.(map[string]interface{}); !ok || len(ingestionMap) > 0 {
27+
return fmt.Errorf("DataLineageConfig still exists at %s", url)
28+
}
29+
}
30+
31+
return nil
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
resource "google_data_lineage_config" "{{$.PrimaryResourceId}}" {
2+
parent = google_folder.integration.name
3+
location = "global"
4+
5+
ingestion {
6+
rule {
7+
integration_selector {
8+
integration = "DATAPROC"
9+
}
10+
lineage_enablement {
11+
enabled = true
12+
}
13+
}
14+
}
15+
depends_on = [time_sleep.wait_for_folder_iam]
16+
}
17+
18+
resource "time_sleep" "wait_for_folder_iam" {
19+
depends_on = [google_folder_iam_member.datalineage_admin]
20+
create_duration = "60s"
21+
}
22+
23+
resource "google_folder" "integration" {
24+
display_name = "{{index $.Vars "folder_name"}}"
25+
parent = "organizations/{{index $.TestEnvVars "organization"}}"
26+
deletion_protection = false
27+
}
28+
29+
resource "google_folder_iam_member" "datalineage_admin" {
30+
folder = google_folder.integration.folder_id
31+
role = "roles/datalineage.admin"
32+
member = "serviceAccount:{{index $.TestEnvVars "service_account"}}"
33+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "google_data_lineage_config" "{{$.PrimaryResourceId}}" {
2+
parent = "organizations/{{index $.TestEnvVars "organization"}}"
3+
location = "global"
4+
5+
ingestion {
6+
rule {
7+
integration_selector {
8+
integration = "LOOKER_CORE"
9+
}
10+
lineage_enablement {
11+
enabled = true
12+
}
13+
}
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "google_data_lineage_config" "{{$.PrimaryResourceId}}" {
2+
parent = "projects/{{index $.TestEnvVars "project"}}"
3+
location = "global"
4+
5+
ingestion {
6+
rule {
7+
integration_selector {
8+
integration = "DATAPROC"
9+
}
10+
lineage_enablement {
11+
enabled = true
12+
}
13+
}
14+
}
15+
}

mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@ var ServicesListBeta = mapOf(
316316
"displayName" to "Datafusion",
317317
"path" to "./google-beta/services/datafusion"
318318
),
319+
"datalineage" to mapOf(
320+
"name" to "datalineage",
321+
"displayName" to "Datalineage",
322+
"path" to "./google-beta/services/datalineage"
323+
),
319324
"datalossprevention" to mapOf(
320325
"name" to "datalossprevention",
321326
"displayName" to "Datalossprevention",

mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@ var ServicesListGa = mapOf(
316316
"displayName" to "Datafusion",
317317
"path" to "./google/services/datafusion"
318318
),
319+
"datalineage" to mapOf(
320+
"name" to "datalineage",
321+
"displayName" to "Datalineage",
322+
"path" to "./google/services/datalineage"
323+
),
319324
"datalossprevention" to mapOf(
320325
"name" to "datalossprevention",
321326
"displayName" to "Datalossprevention",
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package datalineage
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
7+
"github.com/hashicorp/terraform-provider-google/google/registry"
8+
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
9+
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
10+
)
11+
12+
func DataSourceDataLineageConfig() *schema.Resource {
13+
dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceDataLineageConfig().Schema)
14+
tpgresource.AddRequiredFieldsToSchema(dsSchema, "parent", "location")
15+
16+
return &schema.Resource{
17+
Read: dataSourceDataLineageConfigRead,
18+
Schema: dsSchema,
19+
}
20+
}
21+
22+
func dataSourceDataLineageConfigRead(d *schema.ResourceData, meta interface{}) error {
23+
config := meta.(*transport_tpg.Config)
24+
25+
id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/locations/{{location}}/config")
26+
if err != nil {
27+
return fmt.Errorf("error constructing id: %s", err)
28+
}
29+
d.SetId(id)
30+
31+
err = resourceDataLineageConfigRead(d, meta)
32+
if err != nil {
33+
return err
34+
}
35+
36+
if d.Id() == "" {
37+
return fmt.Errorf("%s not found", id)
38+
}
39+
return nil
40+
}
41+
42+
func init() {
43+
registry.Schema{
44+
Name: "google_data_lineage_config",
45+
ProductName: "datalineage",
46+
Type: registry.SchemaTypeDataSource,
47+
Schema: DataSourceDataLineageConfig(),
48+
}.Register()
49+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package datalineage_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 TestAccDataSourceGoogleDataLineageConfig_basic(t *testing.T) {
12+
t.Parallel()
13+
14+
context := map[string]interface{}{
15+
"project": envvar.GetTestProjectFromEnv(),
16+
}
17+
18+
acctest.VcrTest(t, resource.TestCase{
19+
PreCheck: func() { acctest.AccTestPreCheck(t) },
20+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
21+
Steps: []resource.TestStep{
22+
{
23+
Config: testAccDataSourceGoogleDataLineageConfig_basic(context),
24+
Check: resource.ComposeTestCheckFunc(
25+
acctest.CheckDataSourceStateMatchesResourceStateWithIgnores(
26+
"data.google_data_lineage_config.default",
27+
"google_data_lineage_config.default",
28+
[]string{"etag"},
29+
),
30+
),
31+
},
32+
},
33+
})
34+
}
35+
36+
func testAccDataSourceGoogleDataLineageConfig_basic(context map[string]interface{}) string {
37+
return acctest.Nprintf(`
38+
resource "google_data_lineage_config" "default" {
39+
parent = "projects/%{project}"
40+
location = "global"
41+
42+
ingestion {
43+
rule {
44+
integration_selector {
45+
integration = "DATAPROC"
46+
}
47+
lineage_enablement {
48+
enabled = true
49+
}
50+
}
51+
}
52+
}
53+
54+
data "google_data_lineage_config" "default" {
55+
parent = google_data_lineage_config.default.parent
56+
location = google_data_lineage_config.default.location
57+
}
58+
`, context)
59+
}

0 commit comments

Comments
 (0)