Skip to content

Commit

Permalink
chore: iterate
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswuerbach committed Apr 8, 2024
1 parent b068322 commit 9c87e8b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
16 changes: 11 additions & 5 deletions examples/mysql/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
```

<!-- BEGIN_TF_DOCS -->
Expand Down
3 changes: 1 addition & 2 deletions examples/mysql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 1 addition & 0 deletions examples/postgres/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion modules/cloudsql-instance/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -22,7 +25,7 @@ resource "google_sql_database_instance" "main" {
}

database_flags {
name = "cloudsql.iam_authentication"
name = local.iam_authentication_flag
value = "on"
}
}
Expand Down

0 comments on commit 9c87e8b

Please sign in to comment.