Skip to content

Commit

Permalink
datafusion - add args + iam support (GoogleCloudPlatform#6270)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 authored and hao-nan-li committed Dec 6, 2022
1 parent b27a80a commit f729091
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 14 deletions.
40 changes: 40 additions & 0 deletions mmv1/products/datafusion/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ objects:
'Official Documentation':
'https://cloud.google.com/data-fusion/docs/'
api: 'https://cloud.google.com/data-fusion/docs/reference/rest/v1beta1/projects.locations.instances'
iam_policy: !ruby/object:Api::Resource::IamPolicy
parent_resource_attribute: 'name'
method_name_separator: ':'
import_format: ["projects/{{project}}/locations/{{location}}/instances/{{name}}", "{{name}}"]
parameters:
- !ruby/object:Api::Type::String
name: 'region'
Expand Down Expand Up @@ -210,6 +214,26 @@ objects:
project the network should specified in the form of projects/{host-project-id}/global/networks/{network}
required: true
input: true
- !ruby/object:Api::Type::String
name: 'zone'
description: |
Name of the zone in which the Data Fusion instance will be created. Only DEVELOPER instances use this field.
input: true
- !ruby/object:Api::Type::String
name: 'displayName'
description: |
Display name for an instance.
input: true
- !ruby/object:Api::Type::String
name: 'apiEndpoint'
description: |
Endpoint on which the REST APIs is accessible.
output: true
- !ruby/object:Api::Type::String
name: 'p4ServiceAccount'
description: |
P4 service account for the customer project.
output: true
- !ruby/object:Api::Type::NestedObject
name: 'cryptoKeyConfig'
description: |
Expand All @@ -222,3 +246,19 @@ objects:
The name of the key which is used to encrypt/decrypt customer data. For key in Cloud KMS, the key should be in the format of projects/*/locations/*/keyRings/*/cryptoKeys/*.
required: true
input: true
- !ruby/object:Api::Type::NestedObject
name: 'eventPublishConfig'
description: |
Option to enable and pass metadata for event publishing.
properties:
- !ruby/object:Api::Type::Boolean
name: 'enabled'
description: |
Option to enable Event Publishing.
required: true
- !ruby/object:Api::Type::String
name: 'topic'
description: |
The resource name of the Pub/Sub topic. Format: projects/{projectId}/topics/{topic_id}
required: true
input: true
19 changes: 17 additions & 2 deletions mmv1/products/datafusion/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,44 @@
overrides: !ruby/object:Overrides::ResourceOverrides
Instance: !ruby/object:Overrides::Terraform::ResourceOverride
timeouts: !ruby/object:Api::Timeouts
insert_minutes: 60
insert_minutes: 90
update_minutes: 25
delete_minutes: 50
autogen_async: true
examples:
- !ruby/object:Provider::Terraform::Examples
name: "data_fusion_instance_basic"
primary_resource_id: "basic_instance"
primary_resource_name: "fmt.Sprintf(\"tf-test-my-instance%s\", context[\"random_suffix\"])"
vars:
instance_name: "my-instance"
- !ruby/object:Provider::Terraform::Examples
name: "data_fusion_instance_full"
primary_resource_id: "extended_instance"
vars:
instance_name: "my-instance"
ip_alloc: "datafusion-ip-alloc"
network_name: "datafusion-full-network"
- !ruby/object:Provider::Terraform::Examples
name: "data_fusion_instance_cmek"
primary_resource_id: "basic_cmek"
primary_resource_id: "cmek"
vars:
instance_name: "my-instance"
- !ruby/object:Provider::Terraform::Examples
name: "data_fusion_instance_enterprise"
primary_resource_id: "enterprise_instance"
vars:
instance_name: "my-instance"
- !ruby/object:Provider::Terraform::Examples
name: "data_fusion_instance_event"
primary_resource_id: "event"
vars:
instance_name: "my-instance"
- !ruby/object:Provider::Terraform::Examples
name: "data_fusion_instance_zone"
primary_resource_id: "zone"
vars:
instance_name: "my-instance"
custom_code: !ruby/object:Provider::Terraform::CustomCode
pre_update: templates/terraform/pre_update/datafusion_instance_update.go.erb
properties:
Expand All @@ -52,6 +65,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
name: !ruby/object:Overrides::Terraform::PropertyOverride
custom_expand: 'templates/terraform/custom_expand/shortname_to_url.go.erb'
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb'
zone: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
# This is for copying files over
files: !ruby/object:Provider::Config::Files
# These files have templating (ERB) code that will be run.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource "google_data_fusion_instance" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]["instance_name"] %>"
name = "<%= ctx[:vars]["instance_name"] %>"
region = "us-central1"
type = "BASIC"
type = "BASIC"
# Mark for testing to avoid service networking connection usage that is not cleaned up
options = {
prober_test_run = "true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "google_data_fusion_instance" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]["instance_name"] %>"
region = "us-central1"
type = "BASIC"
version = "6.7.0"

event_publish_config {
enabled = true
topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.id
}
}

resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]["instance_name"] %>"
}
36 changes: 26 additions & 10 deletions mmv1/templates/terraform/examples/data_fusion_instance_full.tf.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
resource "google_data_fusion_instance" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]["instance_name"] %>"
description = "My Data Fusion instance"
region = "us-central1"
type = "BASIC"
enable_stackdriver_logging = true
name = "<%= ctx[:vars]["instance_name"] %>"
description = "My Data Fusion instance"
display_name = "My Data Fusion instance"
region = "us-central1"
type = "BASIC"
enable_stackdriver_logging = true
enable_stackdriver_monitoring = true
private_instance = true
version = "6.6.0"
dataproc_service_account = data.google_app_engine_default_service_account.default.email

labels = {
example_key = "example_value"
}
private_instance = true

network_config {
network = "default"
ip_allocation = "10.89.48.0/22"
network = "default"
ip_allocation = "${google_compute_global_address.private_ip_alloc.address}/${google_compute_global_address.private_ip_alloc.prefix_length}"
}
version = "6.3.0"
dataproc_service_account = data.google_app_engine_default_service_account.default.email

# Mark for testing to avoid service networking connection usage that is not cleaned up
options = {
prober_test_run = "true"
Expand All @@ -23,3 +27,15 @@ resource "google_data_fusion_instance" "<%= ctx[:primary_resource_id] %>" {

data "google_app_engine_default_service_account" "default" {
}

resource "google_compute_network" "network" {
name = "<%= ctx[:vars]["network_name"] %>"
}

resource "google_compute_global_address" "private_ip_alloc" {
name = "<%= ctx[:vars]["ip_alloc"] %>"
address_type = "INTERNAL"
purpose = "VPC_PEERING"
prefix_length = 22
network = google_compute_network.network.id
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "google_data_fusion_instance" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]["instance_name"] %>"
region = "us-central1"
zone = "us-central1-a"
type = "DEVELOPER"
}

0 comments on commit f729091

Please sign in to comment.