Skip to content

Commit 3478aaa

Browse files
Added edition field to CloudSQL settings in DMS connection profile (#8602) (#6074)
* feat: added edition field to cloudsql settings * chore: formatted example file Signed-off-by: Modular Magician <[email protected]>
1 parent 6ded477 commit 3478aaa

File tree

4 files changed

+77
-48
lines changed

4 files changed

+77
-48
lines changed

.changelog/8602.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
dms: added `edition` field on the `google_database_migration_service_connection_profile` resource
3+
```

google-beta/services/databasemigrationservice/resource_database_migration_service_connection_profile.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ If the available storage repeatedly falls below the threshold size, Cloud SQL co
234234
Description: `The database engine type and version.
235235
Currently supported values located at https://cloud.google.com/database-migration/docs/reference/rest/v1/projects.locations.connectionProfiles#sqldatabaseversion`,
236236
},
237+
"edition": {
238+
Type: schema.TypeString,
239+
Optional: true,
240+
ValidateFunc: verify.ValidateEnum([]string{"ENTERPRISE", "ENTERPRISE_PLUS", ""}),
241+
Description: `The edition of the given Cloud SQL instance. Possible values: ["ENTERPRISE", "ENTERPRISE_PLUS"]`,
242+
},
237243
"ip_config": {
238244
Type: schema.TypeList,
239245
Optional: true,
@@ -1297,6 +1303,8 @@ func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettings(v interfac
12971303
flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsCollation(original["collation"], d, config)
12981304
transformed["cmek_key_name"] =
12991305
flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsCmekKeyName(original["cmekKeyName"], d, config)
1306+
transformed["edition"] =
1307+
flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsEdition(original["edition"], d, config)
13001308
return []interface{}{transformed}
13011309
}
13021310
func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsDatabaseVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -1427,6 +1435,10 @@ func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsCmekKeyName
14271435
return v
14281436
}
14291437

1438+
func flattenDatabaseMigrationServiceConnectionProfileCloudsqlSettingsEdition(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1439+
return v
1440+
}
1441+
14301442
func flattenDatabaseMigrationServiceConnectionProfileCloudsqlPrivateIp(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
14311443
return v
14321444
}
@@ -2050,6 +2062,13 @@ func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettings(v interface
20502062
transformed["cmekKeyName"] = transformedCmekKeyName
20512063
}
20522064

2065+
transformedEdition, err := expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsEdition(original["edition"], d, config)
2066+
if err != nil {
2067+
return nil, err
2068+
} else if val := reflect.ValueOf(transformedEdition); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2069+
transformed["edition"] = transformedEdition
2070+
}
2071+
20532072
return transformed, nil
20542073
}
20552074

@@ -2238,6 +2257,10 @@ func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsCmekKeyName(
22382257
return v, nil
22392258
}
22402259

2260+
func expandDatabaseMigrationServiceConnectionProfileCloudsqlSettingsEdition(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2261+
return v, nil
2262+
}
2263+
22412264
func expandDatabaseMigrationServiceConnectionProfileCloudsqlPrivateIp(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
22422265
return v, nil
22432266
}

google-beta/services/databasemigrationservice/resource_database_migration_service_connection_profile_generated_test.go

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ resource "google_sql_database_instance" "cloudsqldb" {
7272
7373
resource "google_sql_ssl_cert" "sql_client_cert" {
7474
common_name = "tf-test-my-cert%{random_suffix}"
75-
instance = google_sql_database_instance.cloudsqldb.name
75+
instance = google_sql_database_instance.cloudsqldb.name
7676
7777
depends_on = [google_sql_database_instance.cloudsqldb]
7878
}
@@ -88,21 +88,21 @@ resource "google_sql_user" "sqldb_user" {
8888
8989
9090
resource "google_database_migration_service_connection_profile" "cloudsqlprofile" {
91-
location = "us-central1"
91+
location = "us-central1"
9292
connection_profile_id = "tf-test-my-fromprofileid%{random_suffix}"
93-
display_name = "tf-test-my-fromprofileid%{random_suffix}_display"
93+
display_name = "tf-test-my-fromprofileid%{random_suffix}_display"
9494
labels = {
9595
foo = "bar"
9696
}
9797
mysql {
98-
host = google_sql_database_instance.cloudsqldb.ip_address.0.ip_address
99-
port = 3306
98+
host = google_sql_database_instance.cloudsqldb.ip_address.0.ip_address
99+
port = 3306
100100
username = google_sql_user.sqldb_user.name
101101
password = google_sql_user.sqldb_user.password
102102
ssl {
103-
client_key = google_sql_ssl_cert.sql_client_cert.private_key
103+
client_key = google_sql_ssl_cert.sql_client_cert.private_key
104104
client_certificate = google_sql_ssl_cert.sql_client_cert.cert
105-
ca_certificate = google_sql_ssl_cert.sql_client_cert.server_ca_cert
105+
ca_certificate = google_sql_ssl_cert.sql_client_cert.server_ca_cert
106106
}
107107
cloud_sql_id = "tf-test-my-database%{random_suffix}"
108108
}
@@ -112,9 +112,9 @@ resource "google_database_migration_service_connection_profile" "cloudsqlprofile
112112
113113
114114
resource "google_database_migration_service_connection_profile" "cloudsqlprofile_destination" {
115-
location = "us-central1"
115+
location = "us-central1"
116116
connection_profile_id = "tf-test-my-toprofileid%{random_suffix}"
117-
display_name = "tf-test-my-toprofileid%{random_suffix}_displayname"
117+
display_name = "tf-test-my-toprofileid%{random_suffix}_displayname"
118118
labels = {
119119
foo = "bar"
120120
}
@@ -124,22 +124,21 @@ resource "google_database_migration_service_connection_profile" "cloudsqlprofile
124124
user_labels = {
125125
cloudfoo = "cloudbar"
126126
}
127-
tier = "db-n1-standard-1"
128-
storage_auto_resize_limit = "0"
129-
activation_policy = "ALWAYS"
130-
ip_config {
131-
enable_ipv4 = true
132-
require_ssl = "true"
133-
}
134-
auto_storage_increase = true
135-
data_disk_type = "PD_HDD"
136-
data_disk_size_gb = "11"
137-
zone = "us-central1-b"
138-
source_id = "projects/${data.google_project.project.project_id}/locations/us-central1/connectionProfiles/tf-test-my-fromprofileid%{random_suffix}"
139-
root_password = "testpasscloudsql"
127+
tier = "db-n1-standard-1"
128+
edition = "ENTERPRISE"
129+
storage_auto_resize_limit = "0"
130+
activation_policy = "ALWAYS"
131+
ip_config {
132+
enable_ipv4 = true
133+
require_ssl = true
134+
}
135+
auto_storage_increase = true
136+
data_disk_type = "PD_HDD"
137+
data_disk_size_gb = "11"
138+
zone = "us-central1-b"
139+
source_id = "projects/${data.google_project.project.project_id}/locations/us-central1/connectionProfiles/tf-test-my-fromprofileid%{random_suffix}"
140+
root_password = "testpasscloudsql"
140141
}
141-
142-
143142
}
144143
depends_on = [google_database_migration_service_connection_profile.cloudsqlprofile]
145144
}

website/docs/r/database_migration_service_connection_profile.html.markdown

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ resource "google_sql_database_instance" "cloudsqldb" {
5656
5757
resource "google_sql_ssl_cert" "sql_client_cert" {
5858
common_name = "my-cert"
59-
instance = google_sql_database_instance.cloudsqldb.name
59+
instance = google_sql_database_instance.cloudsqldb.name
6060
6161
depends_on = [google_sql_database_instance.cloudsqldb]
6262
}
@@ -72,21 +72,21 @@ resource "google_sql_user" "sqldb_user" {
7272
7373
7474
resource "google_database_migration_service_connection_profile" "cloudsqlprofile" {
75-
location = "us-central1"
75+
location = "us-central1"
7676
connection_profile_id = "my-fromprofileid"
77-
display_name = "my-fromprofileid_display"
77+
display_name = "my-fromprofileid_display"
7878
labels = {
7979
foo = "bar"
8080
}
8181
mysql {
82-
host = google_sql_database_instance.cloudsqldb.ip_address.0.ip_address
83-
port = 3306
82+
host = google_sql_database_instance.cloudsqldb.ip_address.0.ip_address
83+
port = 3306
8484
username = google_sql_user.sqldb_user.name
8585
password = google_sql_user.sqldb_user.password
8686
ssl {
87-
client_key = google_sql_ssl_cert.sql_client_cert.private_key
87+
client_key = google_sql_ssl_cert.sql_client_cert.private_key
8888
client_certificate = google_sql_ssl_cert.sql_client_cert.cert
89-
ca_certificate = google_sql_ssl_cert.sql_client_cert.server_ca_cert
89+
ca_certificate = google_sql_ssl_cert.sql_client_cert.server_ca_cert
9090
}
9191
cloud_sql_id = "my-database"
9292
}
@@ -96,9 +96,9 @@ resource "google_database_migration_service_connection_profile" "cloudsqlprofile
9696
9797
9898
resource "google_database_migration_service_connection_profile" "cloudsqlprofile_destination" {
99-
location = "us-central1"
99+
location = "us-central1"
100100
connection_profile_id = "my-toprofileid"
101-
display_name = "my-toprofileid_displayname"
101+
display_name = "my-toprofileid_displayname"
102102
labels = {
103103
foo = "bar"
104104
}
@@ -108,22 +108,21 @@ resource "google_database_migration_service_connection_profile" "cloudsqlprofile
108108
user_labels = {
109109
cloudfoo = "cloudbar"
110110
}
111-
tier = "db-n1-standard-1"
112-
storage_auto_resize_limit = "0"
113-
activation_policy = "ALWAYS"
114-
ip_config {
115-
enable_ipv4 = true
116-
require_ssl = "true"
117-
}
118-
auto_storage_increase = true
119-
data_disk_type = "PD_HDD"
120-
data_disk_size_gb = "11"
121-
zone = "us-central1-b"
122-
source_id = "projects/${data.google_project.project.project_id}/locations/us-central1/connectionProfiles/my-fromprofileid"
123-
root_password = "testpasscloudsql"
111+
tier = "db-n1-standard-1"
112+
edition = "ENTERPRISE"
113+
storage_auto_resize_limit = "0"
114+
activation_policy = "ALWAYS"
115+
ip_config {
116+
enable_ipv4 = true
117+
require_ssl = true
118+
}
119+
auto_storage_increase = true
120+
data_disk_type = "PD_HDD"
121+
data_disk_size_gb = "11"
122+
zone = "us-central1-b"
123+
source_id = "projects/${data.google_project.project.project_id}/locations/us-central1/connectionProfiles/my-fromprofileid"
124+
root_password = "testpasscloudsql"
124125
}
125-
126-
127126
}
128127
depends_on = [google_database_migration_service_connection_profile.cloudsqlprofile]
129128
}
@@ -513,6 +512,11 @@ The following arguments are supported:
513512
(Optional)
514513
The KMS key name used for the csql instance.
515514

515+
* `edition` -
516+
(Optional)
517+
The edition of the given Cloud SQL instance.
518+
Possible values are: `ENTERPRISE`, `ENTERPRISE_PLUS`.
519+
516520

517521
<a name="nested_ip_config"></a>The `ip_config` block supports:
518522

0 commit comments

Comments
 (0)