|
| 1 | +# Upgrading to SQL DB 3.0.0 |
| 2 | + |
| 3 | +The 3.0.0 release of SQL DB is a backward incompatible release. The `peering_completed` string variable along with hardcoded "tf_dependency" label in `user_labels` variable used to ensure that resources are created in a proper order when using private IPs and service network peering were dropped from `postgresql` and `safer_mysql` submodules. Instead the `module_depends_on` variable was added to the `postgresql`, `safer_mysql` and `mysql` submodules, which is a list of modules/resources a submodule depends on. |
| 4 | + |
| 5 | +## Migration Instructions |
| 6 | + |
| 7 | +Prior to the 3.0.0 release, you needed to set the optional `peering_completed` input with a string id of a resource that should have been created before the target sql module (e.g. safer_mysql). |
| 8 | + |
| 9 | +```hcl |
| 10 | +// We define a connection with the VPC of the Cloud SQL instance. |
| 11 | +module "private-service-access" { |
| 12 | + source = "GoogleCloudPlatform/sql-db/google//modules/private_service_access" |
| 13 | + project_id = var.project_id |
| 14 | + vpc_network = google_compute_network.default.name |
| 15 | +} |
| 16 | +
|
| 17 | +module "safer-mysql-db" { |
| 18 | + source = "GoogleCloudPlatform/sql-db/google//modules/safer_mysql" |
| 19 | + version = "2.0.0" |
| 20 | +
|
| 21 | + name = "example-safer-mysql-${random_id.name.hex}" |
| 22 | + database_version = var.mysql_version |
| 23 | + project_id = var.project_id |
| 24 | + region = var.region |
| 25 | + zone = "c" |
| 26 | +
|
| 27 | + ... |
| 28 | +
|
| 29 | + assign_public_ip = true |
| 30 | + vpc_network = google_compute_network.default.self_link |
| 31 | +
|
| 32 | + // Used to enforce ordering in the creation of resources. |
| 33 | + peering_completed = module.private-service-access.complete |
| 34 | +} |
| 35 | +
|
| 36 | +``` |
| 37 | + |
| 38 | +With the 3.0.0 release, the `module_depends_on` variable is presented which contains a list of modules/resources that should be created before the target sql module. |
| 39 | + |
| 40 | +```diff |
| 41 | +// We define a connection with the VPC of the Cloud SQL instance. |
| 42 | +module "private-service-access" { |
| 43 | + source = "GoogleCloudPlatform/sql-db/google//modules/private_service_access" |
| 44 | + project_id = var.project_id |
| 45 | + vpc_network = google_compute_network.default.name |
| 46 | +} |
| 47 | + |
| 48 | +module "safer-mysql-db" { |
| 49 | + source = "GoogleCloudPlatform/sql-db/google//modules/safer_mysql" |
| 50 | +- version = "2.0.0" |
| 51 | ++ version = "3.0.0" |
| 52 | + |
| 53 | + name = "example-safer-mysql-${random_id.name.hex}" |
| 54 | + database_version = var.mysql_version |
| 55 | + project_id = var.project_id |
| 56 | + region = var.region |
| 57 | + zone = "c" |
| 58 | + |
| 59 | + ... |
| 60 | + |
| 61 | + assign_public_ip = true |
| 62 | + vpc_network = google_compute_network.default.self_link |
| 63 | + |
| 64 | + // Used to enforce ordering in the creation of resources. |
| 65 | +- peering_completed = module.private-service-access.complete |
| 66 | ++ module_depends_on = [module.private-service-access.complete] |
| 67 | +} |
| 68 | + |
| 69 | +``` |
0 commit comments