Skip to content

Commit cd3dcd6

Browse files
authored
Merge pull request #15 from sparkfabrik/feat/allow_minor_mysql_versions
platform/#3349: allow minor version in MySQL configuration
2 parents 07ccc33 + f904f14 commit cd3dcd6

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres
77
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## [0.4.0] - 2025-01-28
10+
11+
### Changed
12+
13+
- Allow minor versions for MySQL.
914

1015
## [0.3.2] - 2024-10-30
1116

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ CloudSQL Auth Proxy needs the CloudSQL instance to expose a public IP address in
3838
| <a name="input_cloudsql_privileged_user_password"></a> [cloudsql\_privileged\_user\_password](#input\_cloudsql\_privileged\_user\_password) | The password of the privileged user of the Cloud SQL instance | `string` | n/a | yes |
3939
| <a name="input_cloudsql_proxy_host"></a> [cloudsql\_proxy\_host](#input\_cloudsql\_proxy\_host) | The host of the Cloud SQL Auth Proxy; if a value other than localhost or 127.0.0.1 (default) is entered, it is assumed that there is a CloudSQL Auth Proxy instance defined and already configured outside this module, and therefore the proxy will not be launched. | `string` | `"127.0.0.1"` | no |
4040
| <a name="input_cloudsql_proxy_port"></a> [cloudsql\_proxy\_port](#input\_cloudsql\_proxy\_port) | Port of the Cloud SQL Auth Proxy | `string` | `"1234"` | no |
41-
| <a name="input_database_and_user_list"></a> [database\_and\_user\_list](#input\_database\_and\_user\_list) | The list with all the databases and the relative user. Please not that you can assign only a database to a single user, the same user cannot be assigned to multiple databases. `user_host` is optional, has a default value of '%' to allow the user to connect from any host, or you can specify it for the given user for a more restrictive access. | <pre>list(object({<br> user = string<br> user_host = optional(string, "%")<br> database = string<br> }))</pre> | n/a | yes |
41+
| <a name="input_database_and_user_list"></a> [database\_and\_user\_list](#input\_database\_and\_user\_list) | The list with all the databases and the relative user. Please not that you can assign only a database to a single user, the same user cannot be assigned to multiple databases. `user_host` is optional, has a default value of '%' to allow the user to connect from any host, or you can specify it for the given user for a more restrictive access. | <pre>list(object({<br/> user = string<br/> user_host = optional(string, "%")<br/> database = string<br/> }))</pre> | n/a | yes |
4242
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | The ID of the project in which the resource belongs. | `string` | n/a | yes |
4343
| <a name="input_region"></a> [region](#input\_region) | The region in which the resource belongs. | `string` | n/a | yes |
4444
| <a name="input_terraform_start_cloud_sql_proxy"></a> [terraform\_start\_cloud\_sql\_proxy](#input\_terraform\_start\_cloud\_sql\_proxy) | If `true` terraform will automatically start the Cloud SQL Proxy instance present in the filesystem at the condition that cloudsql\_proxy\_host is set to a supported value. If `false` you have to start the Cloud SQL Proxy manually. This variable is used to prevent the creation of a Cloud SQL Proxy instance even if cloudsql\_proxy\_host has a supported value. | `bool` | `true` | no |
@@ -60,5 +60,4 @@ CloudSQL Auth Proxy needs the CloudSQL instance to expose a public IP address in
6060
## Modules
6161

6262
No modules.
63-
6463
<!-- END_TF_DOCS -->

main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ data "google_sql_database_instance" "cloudsql_instance" {
2525
lifecycle {
2626

2727
postcondition {
28-
condition = self.database_version == "MYSQL_5_7" || self.database_version == "MYSQL_8_0"
28+
condition = startswith(self.database_version, "MYSQL_5_7") || startswith(self.database_version, "MYSQL_8_0")
2929
error_message = "Database version must be \"MYSQL_5_7\" or \"MYSQL_8_0\". Other versions are not supported."
3030
}
3131
}

scripts/execute_sql.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ for j in $(seq 1 10); do
2020
done
2121

2222
if [ "$READY" -eq 0 ]; then
23-
if [ "$MYSQL_VERSION" = "MYSQL_5_7" ]; then
23+
if [ "${MYSQL_VERSION:0:9}" = "MYSQL_5_7" ]; then
2424
mysql --host=${CLOUDSQL_PROXY_HOST} --port=${CLOUDSQL_PROXY_PORT} --user=${CLOUDSQL_PRIVILEGED_USER_NAME} --password=${CLOUDSQL_PRIVILEGED_USER_PASSWORD} --execute="REVOKE ALL PRIVILEGES, GRANT OPTION FROM '${USER}'@'${USER_HOST}'; GRANT ALL ON ${DATABASE}.* TO ${USER}@'${USER_HOST}';"
2525
fi
2626

27-
if [ "$MYSQL_VERSION" = "MYSQL_8_0" ]; then
27+
if [ "${MYSQL_VERSION:0:9}" = "MYSQL_8_0" ]; then
2828
mysql --host=${CLOUDSQL_PROXY_HOST} --port=${CLOUDSQL_PROXY_PORT} --user=${CLOUDSQL_PRIVILEGED_USER_NAME} --password=${CLOUDSQL_PRIVILEGED_USER_PASSWORD} --execute="REVOKE cloudsqlsuperuser FROM '${USER}'@'${USER_HOST}'; GRANT ALL ON ${DATABASE}.* TO ${USER}@'${USER_HOST}';"
2929
fi
3030

0 commit comments

Comments
 (0)