forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Database Migration Services - Connection Profile reso…
…urce (GoogleCloudPlatform#7447)
- Loading branch information
1 parent
4b49015
commit f3666e0
Showing
16 changed files
with
1,043 additions
and
0 deletions.
There are no files selected for viewing
577 changes: 577 additions & 0 deletions
577
mmv1/products/databasemigrationservice/connectionprofile.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2022 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: DatabaseMigrationService | ||
display_name: DatabaseMigrationService | ||
versions: | ||
- !ruby/object:Api::Product::Version | ||
name: ga | ||
base_url: https://datamigration.googleapis.com/v1/ | ||
scopes: | ||
- https://www.googleapis.com/auth/cloud-platform | ||
apis_required: | ||
- !ruby/object:Api::Product::ApiReference | ||
name: Database Migration API | ||
url: https://console.cloud.google.com/apis/library/datamigration.googleapis.com |
17 changes: 17 additions & 0 deletions
17
...tabase_migration_service_connection_profile_alloydb_settings_initial_user_password.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2023 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. | ||
-%> | ||
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} { | ||
return d.Get("alloydb.0.settings.0.initial_user.0.password") | ||
} |
17 changes: 17 additions & 0 deletions
17
...tten/database_migration_service_connection_profile_cloudsql_settings_root_password.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2023 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. | ||
-%> | ||
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} { | ||
return d.Get("cloudsql.0.settings.0.root_password") | ||
} |
17 changes: 17 additions & 0 deletions
17
...raform/custom_flatten/database_migration_service_connection_profile_mysql_password.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2023 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. | ||
-%> | ||
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} { | ||
return d.Get("mysql.0.password") | ||
} |
17 changes: 17 additions & 0 deletions
17
...tom_flatten/database_migration_service_connection_profile_mysql_ssl_ca_certificate.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2023 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. | ||
-%> | ||
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} { | ||
return d.Get("mysql.0.ssl.0.ca_certificate") | ||
} |
17 changes: 17 additions & 0 deletions
17
...flatten/database_migration_service_connection_profile_mysql_ssl_client_certificate.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2023 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. | ||
-%> | ||
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} { | ||
return d.Get("mysql.0.ssl.0.client_certificate") | ||
} |
17 changes: 17 additions & 0 deletions
17
.../custom_flatten/database_migration_service_connection_profile_mysql_ssl_client_key.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2023 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. | ||
-%> | ||
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} { | ||
return d.Get("mysql.0.ssl.0.client_key") | ||
} |
17 changes: 17 additions & 0 deletions
17
...m/custom_flatten/database_migration_service_connection_profile_postgresql_password.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2023 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. | ||
-%> | ||
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} { | ||
return d.Get("postgresql.0.password") | ||
} |
17 changes: 17 additions & 0 deletions
17
...latten/database_migration_service_connection_profile_postgresql_ssl_ca_certificate.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2023 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. | ||
-%> | ||
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} { | ||
return d.Get("postgresql.0.ssl.0.ca_certificate") | ||
} |
17 changes: 17 additions & 0 deletions
17
...en/database_migration_service_connection_profile_postgresql_ssl_client_certificate.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2023 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. | ||
-%> | ||
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} { | ||
return d.Get("postgresql.0.ssl.0.client_certificate") | ||
} |
17 changes: 17 additions & 0 deletions
17
...om_flatten/database_migration_service_connection_profile_postgresql_ssl_client_key.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2023 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. | ||
-%> | ||
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} { | ||
return d.Get("postgresql.0.ssl.0.client_key") | ||
} |
60 changes: 60 additions & 0 deletions
60
...templates/terraform/examples/database_migration_service_connection_profile_alloydb.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
data "google_project" "project" { | ||
} | ||
|
||
resource "google_compute_network" "default" { | ||
name = "tf-test-alloydb-cp%{random_suffix}" | ||
} | ||
|
||
resource "google_compute_global_address" "private_ip_alloc" { | ||
name = "private-ip-alloc%{random_suffix}" | ||
address_type = "INTERNAL" | ||
purpose = "VPC_PEERING" | ||
prefix_length = 16 | ||
network = google_compute_network.default.id | ||
|
||
depends_on = [google_compute_network.default] | ||
} | ||
|
||
resource "google_service_networking_connection" "vpc_connection" { | ||
network = google_compute_network.default.id | ||
service = "servicenetworking.googleapis.com" | ||
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name] | ||
|
||
depends_on = [google_compute_global_address.private_ip_alloc] | ||
} | ||
|
||
|
||
resource "google_database_migration_service_connection_profile" "<%= ctx[:primary_resource_id] %>" { | ||
location = "us-central1" | ||
connection_profile_id = "<%= ctx[:vars]["profile"] %>" | ||
display_name = "<%= ctx[:vars]["profile"] %>_display" | ||
labels = { | ||
foo = "bar" | ||
} | ||
alloydb { | ||
cluster_id = "dbmsalloycluster%{random_suffix}" | ||
settings { | ||
initial_user { | ||
user = "alloyuser%{random_suffix}" | ||
password = "alloypass%{random_suffix}" | ||
} | ||
vpc_network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}" | ||
labels = { | ||
alloyfoo = "alloybar" | ||
} | ||
primary_instance_settings { | ||
id = "priminstid" | ||
machine_config { | ||
cpu_count = 2 | ||
} | ||
database_flags = { | ||
} | ||
labels = { | ||
alloysinstfoo = "allowinstbar" | ||
} | ||
} | ||
} | ||
} | ||
|
||
depends_on = [google_service_networking_connection.vpc_connection] | ||
} |
86 changes: 86 additions & 0 deletions
86
...emplates/terraform/examples/database_migration_service_connection_profile_cloudsql.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
data "google_project" "project" { | ||
} | ||
|
||
resource "google_sql_database_instance" "cloudsqldb" { | ||
name = "<%= ctx[:vars]["sqldb"] %>" | ||
database_version = "MYSQL_5_7" | ||
settings { | ||
tier = "db-n1-standard-1" | ||
deletion_protection_enabled = false | ||
} | ||
deletion_protection = false | ||
} | ||
|
||
resource "google_sql_ssl_cert" "sql_client_cert" { | ||
common_name = "<%= ctx[:vars]["sqldb_cert"] %>" | ||
instance = google_sql_database_instance.cloudsqldb.name | ||
|
||
depends_on = [google_sql_database_instance.cloudsqldb] | ||
} | ||
|
||
resource "google_sql_user" "sqldb_user" { | ||
name = "<%= ctx[:vars]["sqldb_user"] %>" | ||
instance = google_sql_database_instance.cloudsqldb.name | ||
password = "<%= ctx[:vars]["sqldb_pass"] %>" | ||
|
||
depends_on = [google_sql_ssl_cert.sql_client_cert] | ||
} | ||
|
||
|
||
|
||
resource "google_database_migration_service_connection_profile" "<%= ctx[:primary_resource_id] %>" { | ||
location = "us-central1" | ||
connection_profile_id = "<%= ctx[:vars]["from_profile"] %>" | ||
display_name = "<%= ctx[:vars]["from_profile"] %>_display" | ||
labels = { | ||
foo = "bar" | ||
} | ||
mysql { | ||
host = google_sql_database_instance.cloudsqldb.ip_address.0.ip_address | ||
port = 3306 | ||
username = google_sql_user.sqldb_user.name | ||
password = google_sql_user.sqldb_user.password | ||
ssl { | ||
client_key = google_sql_ssl_cert.sql_client_cert.private_key | ||
client_certificate = google_sql_ssl_cert.sql_client_cert.cert | ||
ca_certificate = google_sql_ssl_cert.sql_client_cert.server_ca_cert | ||
} | ||
cloud_sql_id = "<%= ctx[:vars]["sqldb"] %>" | ||
} | ||
|
||
depends_on = [google_sql_user.sqldb_user] | ||
} | ||
|
||
|
||
resource "google_database_migration_service_connection_profile" "<%= ctx[:primary_resource_id] %>_destination" { | ||
location = "us-central1" | ||
connection_profile_id = "<%= ctx[:vars]["to_profile"] %>" | ||
display_name = "<%= ctx[:vars]["to_profile"] %>_displayname" | ||
labels = { | ||
foo = "bar" | ||
} | ||
cloudsql { | ||
settings { | ||
database_version = "MYSQL_5_7" | ||
user_labels = { | ||
cloudfoo = "cloudbar" | ||
} | ||
tier = "db-n1-standard-1" | ||
storage_auto_resize_limit = "0" | ||
activation_policy = "ALWAYS" | ||
ip_config { | ||
enable_ipv4 = true | ||
require_ssl = "true" | ||
} | ||
auto_storage_increase = true | ||
data_disk_type = "PD_HDD" | ||
data_disk_size_gb = "11" | ||
zone = "us-central1-b" | ||
source_id = "projects/${data.google_project.project.project_id}/locations/us-central1/connectionProfiles/<%= ctx[:vars]["from_profile"] %>" | ||
root_password = "testpasscloudsql" | ||
} | ||
|
||
|
||
} | ||
depends_on = [google_database_migration_service_connection_profile.<%= ctx[:primary_resource_id] %>] | ||
} |
Oops, something went wrong.