diff --git a/examples/mysql/README.md b/examples/mysql/README.md index f26cd5d..4180617 100644 --- a/examples/mysql/README.md +++ b/examples/mysql/README.md @@ -1,6 +1,7 @@ # Example: mysql resource based on GCP CloudSQL ## Configuration + This example configures a [mysql](https://developer.humanitec.com/platform-orchestrator/reference/resource-types/#mysql) Resource Definition using GCP CloudSQL. A workload using the `mysql` resource to create database instance looks like: ```yaml @@ -24,7 +25,9 @@ resources: ```mermaid graph TD; subgraph VPC - database["MySQl GCP CloudSQL"] + subgraph server["MySQL CloudSQL Database Instance"] + database["CloudSQL Database"] + end subgraph GKE Cluster pod[workload pod] end @@ -36,10 +39,13 @@ graph TD; ```mermaid graph LR; - workload_1 --> db_1["db_1, resource_type: mysql"] - workload_2 --> db_2["db_2, resource_type: mysql"] - workload_2 --> shared.db_1["shared.db_1, resource_type: mysql"] - workload_3 --> shared.db_1["shared.db_1, resource_type: mysql"] + workload_1 --> db_1["db_1, resource_type: mysql"] + workload_2 --> db_2["db_2, resource_type: mysql"] + workload_2 --> shared.db_1["shared.db_1, resource_type: mysql"] + workload_3 --> shared.db_1["shared.db_1, resource_type: mysql"] + db_1 --> server["main-mysql, resource_type: mysql-instance"] + db_2 --> server + shared.db_1 --> server ``` diff --git a/examples/mysql/main.tf b/examples/mysql/main.tf index c07f7bf..c02a2b9 100644 --- a/examples/mysql/main.tf +++ b/examples/mysql/main.tf @@ -91,14 +91,13 @@ module "mysql_instance" { } resource "humanitec_resource_definition_criteria" "mysql_instance" { - resource_definition_id = module.mysql.id + resource_definition_id = module.mysql_instance.id app_id = humanitec_application.example.id class = local.mysql_instance_class res_id = local.mysql_instance_res_id force_delete = true } - module "mysql" { source = "../../humanitec-resource-defs/mysql/basic" diff --git a/examples/postgres/README.md b/examples/postgres/README.md index b307193..7841d4a 100644 --- a/examples/postgres/README.md +++ b/examples/postgres/README.md @@ -1,6 +1,7 @@ # Example: postgres resource based on GCP CloudSQL ## Configuration + This example configures a [postgres](https://developer.humanitec.com/platform-orchestrator/reference/resource-types/#postgres) Resource Definition using GCP CloudSQL. A workload using the `postgres` resource to create database instance looks like: ```yaml diff --git a/modules/cloudsql-instance/basic/main.tf b/modules/cloudsql-instance/basic/main.tf index 4b06336..04cd3e7 100644 --- a/modules/cloudsql-instance/basic/main.tf +++ b/modules/cloudsql-instance/basic/main.tf @@ -2,6 +2,9 @@ locals { # Name restrictions https://cloud.google.com/sql/docs/postgres/instance-settings # The total length of project-ID:instance-ID must be 98 characters or less. default_name = substr("${var.prefix}${var.app_id}-${var.env_id}-${replace(var.res_id, ".", "-")}", 0, 98 - length(var.project)) + + # From https://cloud.google.com/sql/docs/mysql/create-edit-iam-instances#configure-iam-db-instance + iam_authentication_flag = var.port == 5432 ? "cloudsql.iam_authentication" : "cloudsql_iam_authentication" } resource "google_sql_database_instance" "main" { @@ -22,7 +25,7 @@ resource "google_sql_database_instance" "main" { } database_flags { - name = "cloudsql.iam_authentication" + name = local.iam_authentication_flag value = "on" } }