Skip to content

Commit 26b49d6

Browse files
Noremac201melinath
authored andcommitted
Add Dataproc Metastore Database Resource for IAM support (GoogleCloudPlatform#13335)
Co-authored-by: Stephen Lewis (Burrows) <[email protected]>
1 parent 698abe1 commit 26b49d6

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

mmv1/products/metastore/Database.yaml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
name: 'Database'
15+
description: |
16+
Only used to generate IAM resources
17+
# This resource is only used to generate IAM resources. They do not correspond to real
18+
# GCP resources, and should not be used to generate anything other than IAM support.
19+
docs:
20+
base_url: 'projects/{{project}}/locations/{{location}}/services/{{serviceId}}/databases/{{name}}'
21+
self_link: 'projects/{{project}}/locations/{{location}}/services/{{serviceId}}/databases/{{name}}'
22+
import_format:
23+
- 'projects/{{project}}/locations/{{location}}/services/{{serviceId}}/databases/{{name}}'
24+
- '{{name}}'
25+
exclude_resource: true
26+
timeouts:
27+
insert_minutes: 2
28+
update_minutes: 2
29+
delete_minutes: 2
30+
iam_policy:
31+
method_name_separator: ':'
32+
parent_resource_attribute: 'database'
33+
parent_resource_type: "google_dataproc_metastore_service"
34+
example_config_body: "templates/terraform/iam/example_config_body/dataproc_metastore_database_template.tf.tmpl"
35+
import_format:
36+
- 'projects/{{project}}/locations/{{location}}/services/{{serviceId}}/databases/{{name}}'
37+
- '{{name}}'
38+
custom_code:
39+
examples:
40+
- name: 'dataproc_metastore_service_database_iam'
41+
primary_resource_id: 'dpms_service'
42+
primary_resource_name: 'fmt.Sprintf("tf-test-metastore-srv-%s", context["random_suffix"]), "testdb"'
43+
parameters:
44+
properties:
45+
- name: 'name'
46+
type: String
47+
description: Dummy property.
48+
required: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
resource "google_dataproc_metastore_service" "dpms_service" {
2+
service_id = "tf-test-metastore-srv-%{random_suffix}"
3+
location = "us-central1"
4+
5+
tier = "DEVELOPER"
6+
7+
hive_metastore_config {
8+
version = "3.1.2"
9+
}
10+
}
11+
12+
resource "google_dataproc_cluster" "dp_cluster" {
13+
name = "tf-test-dpms-tbl-creator-%{random_suffix}"
14+
region = google_dataproc_metastore_service.dpms_service.location
15+
16+
cluster_config {
17+
# Keep the costs down with smallest config we can get away with
18+
software_config {
19+
override_properties = {
20+
"dataproc:dataproc.allow.zero.workers" = "true"
21+
}
22+
}
23+
24+
endpoint_config {
25+
enable_http_port_access = true
26+
}
27+
28+
master_config {
29+
num_instances = 1
30+
machine_type = "e2-standard-2"
31+
disk_config {
32+
boot_disk_size_gb = 35
33+
}
34+
}
35+
36+
metastore_config {
37+
dataproc_metastore_service = google_dataproc_metastore_service.dpms_service.name
38+
}
39+
}
40+
}
41+
42+
resource "google_dataproc_job" "hive" {
43+
region = google_dataproc_cluster.dp_cluster.region
44+
45+
force_delete = true
46+
placement {
47+
cluster_name = google_dataproc_cluster.dp_cluster.name
48+
}
49+
50+
hive_config {
51+
properties = {
52+
"database" = "testdb"
53+
}
54+
query_list = [
55+
"DROP DATABASE IF EXISTS testdb CASCADE",
56+
"CREATE DATABASE testdb",
57+
]
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
project = google_dataproc_metastore_service.dpms_service.project
3+
location = google_dataproc_metastore_service.dpms_service.location
4+
service_id = google_dataproc_metastore_service.dpms_service.service_id
5+
database = google_dataproc_job.hive.hive_config[0].properties["database"]

0 commit comments

Comments
 (0)