Skip to content

Commit 46c7041

Browse files
authored
Add terraform support for biglake hive database (#18011)
1 parent 3fc3a78 commit 46c7041

3 files changed

Lines changed: 146 additions & 0 deletions

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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: 'HiveDatabase'
16+
description: |
17+
Hive Databases in Biglake Metastore. Hive Databases exist within a Hive Catalog.
18+
references:
19+
guides:
20+
'QUICKSTART_TITLE': 'https://docs.cloud.google.com/lakehouse/docs/about-spark-hive-metastore'
21+
min_version: beta
22+
# hive/v1beta is added here instead of into the base url of the product.yaml.
23+
# This is because the IAM policy does not contain this prefix, so it must be separated.
24+
base_url: 'hive/v1beta/projects/{{project}}/catalogs/{{catalog}}/databases'
25+
self_link: 'hive/v1beta/projects/{{project}}/catalogs/{{catalog}}/databases/{{name}}'
26+
create_url: 'hive/v1beta/projects/{{project}}/catalogs/{{catalog}}/databases?hiveDatabaseId={{name}}'
27+
update_verb: 'PATCH'
28+
update_mask: true
29+
30+
# The IAM policy is shared with Iceberg Catalog (biglakeiceberg).
31+
iam_policy:
32+
method_name_separator: ':'
33+
fetch_iam_policy_verb: GET
34+
allowed_iam_role: roles/biglake.editor
35+
parent_resource_attribute: name
36+
sample_config_body: templates/terraform/iam/example_config_body/biglake_hive_database.tf.tmpl
37+
base_url: v1/projects/{{project}}/catalogs/{{catalog}}/namespaces/{{name}}
38+
import_format:
39+
- projects/{{project}}/catalogs/{{catalog}}/namespaces/{{name}}
40+
- '{{name}}'
41+
42+
samples:
43+
- name: 'biglake_hive_database'
44+
primary_resource_id: 'my_hive_database'
45+
min_version: beta
46+
steps:
47+
- name: 'biglake_hive_database'
48+
resource_id_vars:
49+
bucket_name: example-bucket
50+
vars:
51+
parameters: |
52+
{
53+
key1 = "value1"
54+
key2 = "value2"
55+
}
56+
description: "hive database description"
57+
test_env_vars:
58+
GOOGLE_BILLING_PROJECT: 'PROJECT'
59+
USER_PROJECT_OVERRIDE: 'true'
60+
- name: 'biglake_hive_database'
61+
resource_id_vars:
62+
bucket_name: example-bucket
63+
vars:
64+
parameters: '{key2 = "value2"}'
65+
description: "updated hive database description"
66+
test_env_vars:
67+
GOOGLE_BILLING_PROJECT: 'PROJECT'
68+
USER_PROJECT_OVERRIDE: 'true'
69+
70+
parameters:
71+
- name: 'catalog'
72+
type: String
73+
required: true
74+
immutable: true
75+
url_param_only: true
76+
description: |
77+
Hive catalog where the database to create is located.
78+
- name: 'name'
79+
type: String
80+
required: true
81+
immutable: true
82+
url_param_only: true
83+
description: |
84+
Database to create.
85+
86+
properties:
87+
- name: 'location_uri'
88+
api_name: 'locationUri'
89+
type: String
90+
required: false
91+
description: |
92+
Cloud Storage location path where the database exists. If unspecified, the database will be stored in the catalog location.
93+
Format: gs://bucket/path/to/database
94+
- name: 'description'
95+
type: String
96+
required: false
97+
description: |
98+
Description of the database.
99+
- name: 'parameters'
100+
type: KeyValuePairs
101+
required: false
102+
description: |
103+
Additional parameters associated with the database.
104+
- name: 'create_time'
105+
api_name: 'createTime'
106+
type: String
107+
description: Output only. The creation time of the database.
108+
output: true
109+
- name: 'update_time'
110+
api_name: 'updateTime'
111+
type: String
112+
description: Output only. The update time of the database.
113+
output: true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
project = google_biglake_hive_database.my_hive_database.project
2+
catalog = google_biglake_hive_database.my_hive_database.catalog
3+
name = google_biglake_hive_database.my_hive_database.name
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
terraform {
2+
required_providers {
3+
google = {
4+
source = "hashicorp/google-beta"
5+
}
6+
}
7+
}
8+
9+
resource "google_storage_bucket" "bucket" {
10+
name = "{{index $.ResourceIdVars "bucket_name"}}"
11+
location = "us-central1"
12+
force_destroy = true
13+
uniform_bucket_level_access = true
14+
}
15+
16+
resource "google_biglake_hive_catalog" "catalog" {
17+
name = "tf_test_catalog%{random_suffix}"
18+
primary_location = "us-central1"
19+
location_uri = "gs://${google_storage_bucket.bucket.name}"
20+
}
21+
22+
resource "google_biglake_hive_database" "{{$.PrimaryResourceId}}" {
23+
catalog = google_biglake_hive_catalog.catalog.name
24+
name = "tf_test_database%{random_suffix}"
25+
location_uri = "gs://${google_storage_bucket.bucket.name}"
26+
27+
parameters = {{index $.Vars "parameters"}}
28+
29+
description = "{{index $.Vars "description"}}"
30+
}

0 commit comments

Comments
 (0)