Skip to content

Commit a33434f

Browse files
authored
feat: add output required for apphub registration for mysql/postgresql module (#704)
1 parent c3885a5 commit a33434f

File tree

6 files changed

+45
-4
lines changed

6 files changed

+45
-4
lines changed

modules/mysql/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ module "mysql-db" {
111111
| Name | Description |
112112
|------|-------------|
113113
| additional\_users | List of maps of additional users and passwords |
114+
| apphub\_service\_uri | Service URI in CAIS style to be used by Apphub. |
114115
| env\_vars | Exported environment variables |
115116
| generated\_user\_password | The auto generated default user password if not input password was provided |
116117
| iam\_users | The list of the IAM users with access to the CloudSQL instance |

modules/mysql/metadata.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ spec:
8181
description: The database version to use
8282
varType: string
8383
required: true
84+
- name: maintenance_version
85+
description: The current software version on the instance. This attribute can not be set during creation. Refer to available_maintenance_versions attribute to see what maintenance_version are available for upgrade. When this attribute gets updated, it will cause an instance restart. Setting a maintenance_version value that is older than the current one on the instance will be ignored
86+
varType: string
8487
- name: availability_type
8588
description: The availability type for the master instance. Can be either `REGIONAL` or `null`.
8689
varType: string
@@ -308,9 +311,10 @@ spec:
308311
varType: |-
309312
object({
310313
enable_password_policy = bool
311-
min_length = number
312-
complexity = string
313-
disallow_username_substring = bool
314+
min_length = optional(number)
315+
complexity = optional(string)
316+
disallow_username_substring = optional(bool)
317+
reuse_interval = optional(number)
314318
})
315319
- name: read_replicas
316320
description: List of read replicas to create. Encryption key is required for replica in different region. For replica in same region as master set encryption_key_name = null
@@ -412,6 +416,13 @@ spec:
412416
type:
413417
- tuple
414418
- []
419+
- name: apphub_service_uri
420+
description: Service URI in CAIS style to be used by Apphub.
421+
type:
422+
- object
423+
- location: string
424+
service_id: string
425+
service_uri: string
415426
- name: env_vars
416427
description: Exported environment variables
417428
type:

modules/mysql/outputs.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,12 @@ output "env_vars" {
154154
"CLOUD_SQL_DATABASE_NAME" : local.database_name
155155
}
156156
}
157+
158+
output "apphub_service_uri" {
159+
value = {
160+
service_uri = "//cloudsql.googleapis.com/projects${element(split("/projects", google_sql_database_instance.default.self_link), 1)}"
161+
service_id = substr("${var.name}-${md5("${var.region}-${var.project_id}")}", 0, 63)
162+
location = var.region
163+
}
164+
description = "Service URI in CAIS style to be used by Apphub."
165+
}

modules/postgresql/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ module "pg" {
181181
| Name | Description |
182182
|------|-------------|
183183
| additional\_users | List of maps of additional users and passwords |
184+
| apphub\_service\_uri | Service URI in CAIS style to be used by Apphub. |
184185
| dns\_name | DNS name of the instance endpoint |
185186
| env\_vars | Exported environment variables |
186187
| generated\_user\_password | The auto generated default user password if not input password was provided |

modules/postgresql/metadata.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,12 @@ spec:
7878
description: The edition of the Cloud SQL instance, can be ENTERPRISE or ENTERPRISE_PLUS.
7979
varType: string
8080
- name: database_version
81-
description: The database version to use
81+
description: The database version to use. Can be 9_6, 14, 15, 16, 17.
8282
varType: string
8383
required: true
84+
- name: maintenance_version
85+
description: The current software version on the instance. This attribute can not be set during creation. Refer to available_maintenance_versions attribute to see what maintenance_version are available for upgrade. When this attribute gets updated, it will cause an instance restart. Setting a maintenance_version value that is older than the current one on the instance will be ignored
86+
varType: string
8487
- name: availability_type
8588
description: The availability type for the Cloud SQL instance.This is only used to set up high availability for the PostgreSQL instance. Can be either `ZONAL` or `REGIONAL`.
8689
varType: string
@@ -403,6 +406,13 @@ spec:
403406
type:
404407
- tuple
405408
- []
409+
- name: apphub_service_uri
410+
description: Service URI in CAIS style to be used by Apphub.
411+
type:
412+
- object
413+
- location: string
414+
service_id: string
415+
service_uri: string
406416
- name: dns_name
407417
description: DNS name of the instance endpoint
408418
type: string

modules/postgresql/outputs.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,12 @@ output "env_vars" {
152152
"CLOUD_SQL_DATABASE_NAME" : local.database_name
153153
}
154154
}
155+
156+
output "apphub_service_uri" {
157+
value = {
158+
service_uri = "//cloudsql.googleapis.com/projects${element(split("/projects", google_sql_database_instance.default.self_link), 1)}"
159+
service_id = substr("${var.name}-${md5("${var.region}-${var.project_id}")}", 0, 63)
160+
location = var.region
161+
}
162+
description = "Service URI in CAIS style to be used by Apphub."
163+
}

0 commit comments

Comments
 (0)