Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add google_dataproc_metastore_service #4486

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mmv1/products/cloudrun/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ overrides: !ruby/object:Overrides::ResourceOverrides
name: 'autogenerate_revision_name'
default_value: false
description: |
If set to `true`, the revision name (template.metadata.name) will be omitted and
autogenerated by Cloud Run. This cannot be set to `true` while `template.metadata.name`
is also set.
If set to `true`, the revision name (template.metadata.name) will be omitted and
autogenerated by Cloud Run. This cannot be set to `true` while `template.metadata.name`
is also set.
(For legacy support, if `template.metadata.name` is unset in state while
this field is set to false, the revision name will still autogenerate.)
custom_code: !ruby/object:Provider::Terraform::CustomCode
Expand Down
2 changes: 1 addition & 1 deletion mmv1/products/dataproc/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ objects:
The version of software inside the cluster. It must be one of the supported Cloud Dataproc
Versions, such as "1.2" (including a subminor version, such as "1.2.29"), or the "preview"
version.
- !ruby/object:Api::Type::KeyValuePairs
- !ruby/object:Api::Type::KeyValuePairs
name: 'properties'
description: |
The properties to set on daemon config files.
Expand Down
190 changes: 190 additions & 0 deletions mmv1/products/metastore/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
# Copyright 2021 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

--- !ruby/object:Api::Product
name: DataprocMetastore
versions:
- !ruby/object:Api::Product::Version
name: beta
base_url: https://metastore.googleapis.com/v1beta/
scopes:
- https://www.googleapis.com/auth/cloud-identity
apis_required:
- !ruby/object:Api::Product::ApiReference
name: Dataproc Metastore API
url: https://console.cloud.google.com/apis/library/metastore.googleapis.com
objects:
- !ruby/object:Api::Resource
name: 'Service'
base_url: "projects/{{project}}/locations/{{location}}/services"
create_url: 'projects/{{project}}/locations/{{location}}/services?serviceId={{service_id}}'
self_link: "projects/{{project}}/locations/{{location}}/services/{{service_id}}"
update_verb: :PATCH
update_mask: true
min_version: beta
description: |
A managed metastore service that serves metadata queries.
async: !ruby/object:Api::OpAsync
operation: !ruby/object:Api::OpAsync::Operation
path: 'name'
base_url: '{{op_id}}'
wait_ms: 1000
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 40
update_minutes: 40
delete_minutes: 40
result: !ruby/object:Api::OpAsync::Result
path: 'response'
status: !ruby/object:Api::OpAsync::Status
path: 'done'
complete: true
allowed:
- true
- false
error: !ruby/object:Api::OpAsync::Error
path: 'error'
message: 'message'
parameters:
- !ruby/object:Api::Type::String
name: 'serviceId'
required: true
input: true
url_param_only: true
description: |
The ID of the metastore service. The id must contain only letters (a-z, A-Z), numbers (0-9), underscores (_),
and hyphens (-). Cannot begin or end with underscore or hyphen. Must consist of between
3 and 63 characters.
- !ruby/object:Api::Type::String
name: 'location'
url_param_only: true
input: true
default_value: global
description: |
The location where the autoscaling policy should reside.
The default value is `global`.
properties:
- !ruby/object:Api::Type::String
name: 'name'
output: true
description: |
The relative resource name of the metastore service.
- !ruby/object:Api::Type::KeyValuePairs
name: 'labels'
description: 'User-defined labels for the metastore service.'
# This is an x-product resource reference.
- !ruby/object:Api::Type::String
name: 'network'
input: true
description: |
The relative resource name of the VPC network on which the instance can be accessed. It is specified in the following form:

"projects/{projectNumber}/global/networks/{network_id}".
- !ruby/object:Api::Type::String
name: 'endpointUri'
output: true
description: |
The URI of the endpoint used to access the metastore service.
- !ruby/object:Api::Type::Integer
name: 'port'
description: |
The TCP port at which the metastore service is reached. Default: 9083.
- !ruby/object:Api::Type::String
name: 'state'
output: true
description: |
The current state of the metastore service.
- !ruby/object:Api::Type::String
name: 'stateMessage'
output: true
description: |
Additional information about the current state of the metastore service, if available.
- !ruby/object:Api::Type::String
name: 'artifactGcsUri'
output: true
description: |
A Cloud Storage URI (starting with gs://) that specifies where artifacts related to the metastore service are stored.
- !ruby/object:Api::Type::Enum
name: 'tier'
description: |
The tier of the service.
values:
- :DEVELOPER
- :ENTERPRISE
- !ruby/object:Api::Type::NestedObject
name: 'maintenanceWindow'
description: |
The one hour maintenance window of the metastore service.
This specifies when the service can be restarted for maintenance purposes in UTC time.
properties:
- !ruby/object:Api::Type::Integer
name: 'hourOfDay'
ScottSuarez marked this conversation as resolved.
Show resolved Hide resolved
description: |
The hour of day (0-23) when the window starts.
required: true
- !ruby/object:Api::Type::Enum
name: 'dayOfWeek'
description: |
The day of week, when the window starts.
required: true
values:
- :MONDAY
- :TUESDAY
- :WEDNESDAY
- :THURSDAY
- :FRIDAY
- :SATURDAY
- :SUNDAY
- !ruby/object:Api::Type::NestedObject
name: 'hiveMetastoreConfig'
ScottSuarez marked this conversation as resolved.
Show resolved Hide resolved
description: |
Configuration information specific to running Hive metastore software as the metastore service.
properties:
- !ruby/object:Api::Type::String
name: 'version'
input: true
required: true
description: |
The Hive metastore schema version.
- !ruby/object:Api::Type::KeyValuePairs
name: 'configOverrides'
description: |
A mapping of Hive metastore configuration key-value pairs to apply to the Hive metastore (configured in hive-site.xml).
The mappings override system defaults (some keys cannot be overridden)
- !ruby/object:Api::Type::NestedObject
name: 'kerberosConfig'
description: |
Information used to configure the Hive metastore service as a service principal in a Kerberos realm.
properties:
- !ruby/object:Api::Type::NestedObject
name: 'keytab'
ScottSuarez marked this conversation as resolved.
Show resolved Hide resolved
required: true
description: |
A Kerberos keytab file that can be used to authenticate a service principal with a Kerberos Key Distribution Center (KDC).
properties:
- !ruby/object:Api::Type::String
required: true
name: 'cloudSecret'
ScottSuarez marked this conversation as resolved.
Show resolved Hide resolved
ScottSuarez marked this conversation as resolved.
Show resolved Hide resolved
description: |
The relative resource name of a Secret Manager secret version, in the following form:

"projects/{projectNumber}/secrets/{secret_id}/versions/{version_id}".
- !ruby/object:Api::Type::String
name: 'principal'
ScottSuarez marked this conversation as resolved.
Show resolved Hide resolved
required: true
description: |
A Kerberos principal that exists in the both the keytab the KDC to authenticate as. A typical principal is of the form "primary/instance@REALM", but there is no exact format.
- !ruby/object:Api::Type::String
name: 'krb5ConfigGcsUri'
required: true
description: |
A Cloud Storage URI that specifies the path to a krb5.conf file. It is of the form gs://{bucket_name}/path/to/krb5.conf, although the file does not need to be named krb5.conf explicitly.
35 changes: 35 additions & 0 deletions mmv1/products/metastore/terraform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2021 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

--- !ruby/object:Provider::Terraform::Config
overrides: !ruby/object:Overrides::ResourceOverrides
Service: !ruby/object:Overrides::Terraform::ResourceOverride
autogen_async: true
import_format: ["projects/{{project}}/locations/{{location}}/services/{{service_id}}"]
examples:
- !ruby/object:Provider::Terraform::Examples
name: "dataproc_metastore_service_basic"
min_version: beta
primary_resource_id: "default"
vars:
metastore_service_name: "metastore-srv"
properties:
network: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
port: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
tier: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
hiveMetastoreConfig.configOverrides: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
diff_suppress_func: 'dataprocMetastoreServiceOverrideSuppress'
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resource "google_dataproc_metastore_service" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
service_id = "<%= ctx[:vars]['metastore_service_name'] %>"
location = "us-central1"
port = 9080
tier = "DEVELOPER"

maintenance_window {
hour_of_day = 2
day_of_week = "SUNDAY"
}

hive_metastore_config {
version = "2.3.6"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<% autogen_exception -%>
package google
<% unless version == 'ga' -%>

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccDataprocMetastoreService_updateAndImport(t *testing.T) {
t.Parallel()

name := "tf-metastore-" + randString(t, 10)
tier := [2]string{"DEVELOPER", "ENTERPRISE"}

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckBigqueryReservationReservationDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccDataprocMetastoreService_updateAndImport(name, tier[0]),
},
{
ResourceName: "google_dataproc_metastore_service.my_metastore",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccDataprocMetastoreService_updateAndImport(name, tier[1]),
},
{
ResourceName: "google_dataproc_metastore_service.my_metastore",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccDataprocMetastoreService_updateAndImport(name, tier string) string {
return fmt.Sprintf(`
resource "google_dataproc_metastore_service" "my_metastore" {
service_id = "%s"
location = "us-central1"
tier = "%s"

hive_metastore_config {
version = "2.3.6"
}
}
`, name, tier)
}
<% else %>
// Magic Modules doesn't let us remove files - blank out beta-only common-compile files for now.
<% end -%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<% autogen_exception -%>
package google
ScottSuarez marked this conversation as resolved.
Show resolved Hide resolved
<% unless version == 'ga' -%>

import (
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

const dataprocMetastoreProvidedOverride = "hive.metastore.warehouse.dir"

func dataprocMetastoreServiceOverrideSuppress(k, old, new string, d *schema.ResourceData) bool {
// Suppress diffs for the label provided by Google
if strings.Contains(k, dataprocMetastoreProvidedOverride) && new == "" {
ScottSuarez marked this conversation as resolved.
Show resolved Hide resolved
return true
}

// Let diff be determined by labels (above)
if strings.Contains(k, "hive_metastore_config.0.config_overrides.%") {
return true
}

// For other keys, don't suppress diff.
return false
}
<% end -%>