Skip to content

Commit 39a3e97

Browse files
committed
2 parents 16c3e2d + c80771e commit 39a3e97

8 files changed

Lines changed: 602 additions & 316 deletions

File tree

mmv1/products/bigqueryconnection/Connection.yaml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,21 @@ examples:
153153
ignore_read_extra:
154154
# password removed
155155
- 'cloud_sql.0.credential'
156+
- name: 'bigquery_connection_connector_configuration'
157+
primary_resource_id: 'connection'
158+
vars:
159+
connection_id: 'my-connection'
160+
username: 'user'
161+
password: 'password'
162+
test_vars_overrides:
163+
username: '"user" + randomSuffix'
164+
ignore_read_extra:
165+
# username and password are not returned by the API
166+
- 'configuration.0.authentication.0.username_password.0.username'
167+
- 'configuration.0.authentication.0.username_password.0.password'
168+
external_providers: ["random", "time"]
169+
# Random provider
170+
skip_vcr: true
156171
parameters:
157172
properties:
158173
- name: 'name'
@@ -209,6 +224,7 @@ properties:
209224
- 'cloud_spanner'
210225
- 'cloud_resource'
211226
- 'spark'
227+
- 'configuration'
212228
properties:
213229
- name: 'instanceId'
214230
type: String
@@ -261,6 +277,7 @@ properties:
261277
- 'cloud_spanner'
262278
- 'cloud_resource'
263279
- 'spark'
280+
- 'configuration'
264281
properties:
265282
- name: 'accessRole'
266283
type: NestedObject
@@ -295,6 +312,7 @@ properties:
295312
- 'cloud_spanner'
296313
- 'cloud_resource'
297314
- 'spark'
315+
- 'configuration'
298316
properties:
299317
- name: 'application'
300318
type: String
@@ -340,6 +358,7 @@ properties:
340358
- 'cloud_spanner'
341359
- 'cloud_resource'
342360
- 'spark'
361+
- 'configuration'
343362
properties:
344363
- name: 'database'
345364
type: String
@@ -397,6 +416,7 @@ properties:
397416
- 'cloud_spanner'
398417
- 'cloud_resource'
399418
- 'spark'
419+
- 'configuration'
400420
properties:
401421
- name: 'serviceAccountId'
402422
type: String
@@ -416,6 +436,7 @@ properties:
416436
- 'cloud_spanner'
417437
- 'cloud_resource'
418438
- 'spark'
439+
- 'configuration'
419440
properties:
420441
- name: 'serviceAccountId'
421442
type: String
@@ -436,3 +457,94 @@ properties:
436457
- name: 'dataprocCluster'
437458
type: String
438459
description: Resource name of an existing Dataproc Cluster to act as a Spark History Server for the connection if the form of projects/[projectId]/regions/[region]/clusters/[cluster_name].
460+
- name: 'configuration'
461+
type: NestedObject
462+
description: |
463+
Connector configuration. This is a generic configuration that is used to connect to
464+
external data sources such as AlloyDB, MySQL, and PostgreSQL using the BigQuery
465+
Connector framework.
466+
exactly_one_of:
467+
- 'cloud_sql'
468+
- 'aws'
469+
- 'azure'
470+
- 'cloud_spanner'
471+
- 'cloud_resource'
472+
- 'spark'
473+
- 'configuration'
474+
properties:
475+
- name: 'connectorId'
476+
type: String
477+
description: |
478+
The ID of the connector. Possible values include `google-alloydb`, `google-cloudsql-mysql`,
479+
`google-cloudsql-postgres`, and other connector IDs supported by the BigQuery Connector framework.
480+
required: true
481+
immutable: true
482+
- name: 'endpoint'
483+
type: NestedObject
484+
description: Endpoint configuration for the connector.
485+
properties:
486+
- name: 'hostPort'
487+
type: String
488+
description: |
489+
Host and port in the format of `host:port` for the connector endpoint.
490+
- name: 'authentication'
491+
type: NestedObject
492+
description: Authentication configuration for the connector.
493+
properties:
494+
- name: 'usernamePassword'
495+
type: NestedObject
496+
description: Username/password authentication configuration.
497+
custom_flatten: 'templates/terraform/custom_flatten/bigquery_connection_configuration_authentication_flatten.go.tmpl'
498+
properties:
499+
- name: 'username'
500+
type: String
501+
description: Username for the connector.
502+
required: true
503+
- name: 'password'
504+
type: NestedObject
505+
description: Password configuration for the connector.
506+
required: true
507+
properties:
508+
- name: 'plaintext'
509+
type: String
510+
description: The plaintext password.
511+
required: true
512+
sensitive: true
513+
- name: 'secretType'
514+
type: String
515+
description: |
516+
Output only. The type of the secret.
517+
output: true
518+
- name: 'serviceAccount'
519+
type: String
520+
description: |
521+
Output only. The service account used for authenticating with the connector.
522+
output: true
523+
- name: 'network'
524+
type: NestedObject
525+
description: Network configuration for the connector.
526+
properties:
527+
- name: 'privateServiceConnect'
528+
type: NestedObject
529+
description: Private Service Connect configuration for the connector.
530+
properties:
531+
- name: 'networkAttachment'
532+
type: String
533+
description: |
534+
The resource name of a network attachment in the format of
535+
`projects/{project}/regions/{region}/networkAttachments/{networkAttachment}`.
536+
required: true
537+
- name: 'asset'
538+
type: NestedObject
539+
description: Asset configuration for the connector.
540+
required: true
541+
properties:
542+
- name: 'database'
543+
type: String
544+
description: The name of the database.
545+
- name: 'googleCloudResource'
546+
type: String
547+
description: |
548+
The full resource name of the Google Cloud resource.
549+
For AlloyDB, this is in the format of
550+
`//alloydb.googleapis.com/projects/{project}/locations/{region}/clusters/{cluster}/instances/{instance}`.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{/*
2+
The license inside this block applies to this file
3+
Copyright 2024 Google Inc.
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/ -}}
13+
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
14+
return []interface{}{
15+
map[string]interface{}{
16+
"username": d.Get("configuration.0.authentication.0.username_password.0.username"),
17+
"password": []interface{}{
18+
map[string]interface{}{
19+
"plaintext": d.Get("configuration.0.authentication.0.username_password.0.password.0.plaintext"),
20+
},
21+
},
22+
},
23+
}
24+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
resource "google_alloydb_cluster" "default" {
2+
cluster_id = "alloydb-cluster-${local.name_suffix}"
3+
location = "us-central1"
4+
network_config {
5+
network = google_compute_network.default.id
6+
}
7+
8+
initial_user {
9+
password = "alloydb-cluster-password"
10+
}
11+
12+
deletion_protection = false
13+
14+
lifecycle {
15+
ignore_changes = [initial_user]
16+
}
17+
}
18+
19+
resource "google_alloydb_instance" "default" {
20+
cluster = google_alloydb_cluster.default.name
21+
instance_id = "alloydb-instance-${local.name_suffix}"
22+
instance_type = "PRIMARY"
23+
24+
machine_config {
25+
cpu_count = 2
26+
}
27+
28+
depends_on = [google_service_networking_connection.vpc_connection]
29+
}
30+
31+
resource "google_compute_network" "default" {
32+
name = "alloydb-network-${local.name_suffix}"
33+
}
34+
35+
resource "google_compute_global_address" "private_ip_alloc" {
36+
name = "alloydb-ip-${local.name_suffix}"
37+
address_type = "INTERNAL"
38+
purpose = "VPC_PEERING"
39+
prefix_length = 16
40+
network = google_compute_network.default.id
41+
}
42+
43+
resource "google_service_networking_connection" "vpc_connection" {
44+
network = google_compute_network.default.id
45+
service = "servicenetworking.googleapis.com"
46+
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
47+
}
48+
49+
locals {
50+
name_suffix = "{{index $.Vars "connection_id"}}"
51+
}
52+
53+
resource "google_bigquery_connection" "{{$.PrimaryResourceId}}" {
54+
connection_id = "{{index $.Vars "connection_id"}}"
55+
location = "us-central1"
56+
friendly_name = "alloydb connection"
57+
description = "AlloyDB connection using connector configuration"
58+
59+
configuration {
60+
connector_id = "google-alloydb"
61+
asset {
62+
database = "postgres"
63+
google_cloud_resource = "//alloydb.googleapis.com/${google_alloydb_instance.default.id}"
64+
}
65+
authentication {
66+
username_password {
67+
username = "{{index $.Vars "username"}}"
68+
password {
69+
plaintext = "{{index $.Vars "password"}}"
70+
}
71+
}
72+
}
73+
}
74+
}

mmv1/third_party/terraform/services/assuredworkloads/resource_assured_workloads_workload.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func ResourceAssuredWorkloadsWorkload() *schema.Resource {
100100
Type: schema.TypeString,
101101
Optional: true,
102102
ForceNew: true,
103-
Description: "Optional. Partner regime associated with this workload. Possible values: PARTNER_UNSPECIFIED, LOCAL_CONTROLS_BY_S3NS, SOVEREIGN_CONTROLS_BY_T_SYSTEMS, SOVEREIGN_CONTROLS_BY_SIA_MINSAIT, SOVEREIGN_CONTROLS_BY_PSN, SOVEREIGN_CONTROLS_BY_CNTXT, SOVEREIGN_CONTROLS_BY_CNTXT_NO_EKM",
103+
Description: "Optional. Partner regime associated with this workload. Possible values: PARTNER_UNSPECIFIED, LOCAL_CONTROLS_BY_S3NS, SOVEREIGN_CONTROLS_BY_T_SYSTEMS, SOVEREIGN_CONTROLS_BY_SIA_MINSAIT, SOVEREIGN_CONTROLS_BY_PSN, SOVEREIGN_CONTROLS_BY_CNTXT, SOVEREIGN_CONTROLS_BY_CNTXT_NO_EKM, SPAIN_DATA_BOUNDARY_BY_TELEFONICA",
104104
},
105105

106106
"partner_permissions": {

mmv1/third_party/terraform/services/assuredworkloads/workload.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func (v WorkloadPartnerEnum) Validate() error {
218218
// Empty enum is okay.
219219
return nil
220220
}
221-
for _, s := range []string{"PARTNER_UNSPECIFIED", "LOCAL_CONTROLS_BY_S3NS", "SOVEREIGN_CONTROLS_BY_T_SYSTEMS", "SOVEREIGN_CONTROLS_BY_SIA_MINSAIT", "SOVEREIGN_CONTROLS_BY_PSN", "SOVEREIGN_CONTROLS_BY_CNTXT", "SOVEREIGN_CONTROLS_BY_CNTXT_NO_EKM"} {
221+
for _, s := range []string{"PARTNER_UNSPECIFIED", "LOCAL_CONTROLS_BY_S3NS", "SOVEREIGN_CONTROLS_BY_T_SYSTEMS", "SOVEREIGN_CONTROLS_BY_SIA_MINSAIT", "SOVEREIGN_CONTROLS_BY_PSN", "SOVEREIGN_CONTROLS_BY_CNTXT", "SOVEREIGN_CONTROLS_BY_CNTXT_NO_EKM", "SPAIN_DATA_BOUNDARY_BY_TELEFONICA"} {
222222
if string(v) == s {
223223
return nil
224224
}

0 commit comments

Comments
 (0)