Skip to content

Commit

Permalink
chore: Add Apphub URI output to Cloud SQL modules (#657)
Browse files Browse the repository at this point in the history
Co-authored-by: abhishek kumar tiwari <[email protected]>
  • Loading branch information
tjy9206 and q2w authored Oct 23, 2024
1 parent 003237e commit 29d5099
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 6 deletions.
1 change: 1 addition & 0 deletions modules/mssql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ module "mssql" {
| Name | Description |
|------|-------------|
| additional\_users | List of maps of additional users and passwords |
| apphub\_service\_uri | Service URI in CAIS style to be used by Apphub. |
| generated\_user\_password | The auto generated default user password if not input password was provided |
| instance\_address | The IPv4 addesses assigned for the master instance |
| instance\_connection\_name | The connection name of the master instance to be used in connection strings |
Expand Down
3 changes: 3 additions & 0 deletions modules/mssql/metadata.display.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ spec:
create_timeout:
name: create_timeout
title: Create Timeout
data_cache_enabled:
name: data_cache_enabled
title: Data Cache Enabled
database_flags:
name: database_flags
title: Database Flags
Expand Down
15 changes: 15 additions & 0 deletions modules/mssql/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ spec:
type:
- tuple
- []
- name: apphub_service_uri
description: Service URI in CAIS style to be used by Apphub.
type:
- object
- service_id: string
service_uri: string
- name: generated_user_password
description: The auto generated default user password if not input password was provided
type: string
Expand Down Expand Up @@ -564,3 +570,12 @@ spec:
- serviceusage.googleapis.com
- sqladmin.googleapis.com
- workflows.googleapis.com
providerVersions:
- source: hashicorp/google
version: ">= 5.12, < 7"
- source: hashicorp/google-beta
version: ">= 5.12, < 7"
- source: hashicorp/null
version: ~> 3.2
- source: hashicorp/random
version: ~> 3.4
8 changes: 8 additions & 0 deletions modules/mssql/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,11 @@ output "primary" {
description = "The `google_sql_database_instance` resource representing the primary instance"
sensitive = true
}

output "apphub_service_uri" {
value = {
service_uri = "//cloudsql.googleapis.com/projects${element(split("/projects", google_sql_database_instance.default.self_link), 1)}"
service_id = substr(format("%s-%s", var.name, md5(var.project_id)), 0, 63)
}
description = "Service URI in CAIS style to be used by Apphub."
}
1 change: 1 addition & 0 deletions modules/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
| Name | Description |
|------|-------------|
| additional\_users | List of maps of additional users and passwords |
| apphub\_service\_uri | Service URI in CAIS style to be used by Apphub. |
| env\_vars | Exported environment variables |
| generated\_user\_password | The auto generated default user password if not input password was provided |
| iam\_users | The list of the IAM users with access to the CloudSQL instance |
Expand Down
21 changes: 18 additions & 3 deletions modules/mysql/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ spec:
connections:
- source:
source: github.com/terraform-google-modules/terraform-google-network//modules/vpc
version: "~> 9.1.0"
version: ~> 9.1.0
spec:
outputExpr: network_id
inputPath: private_network
Expand Down Expand Up @@ -339,12 +339,12 @@ spec:
connections:
- source:
source: github.com/terraform-google-modules/terraform-google-service-accounts//modules/simple-sa
version: "~> 4.3.0"
version: ~> 4.3.0
spec:
outputExpr: id
- source:
source: github.com/GoogleCloudPlatform/terraform-google-cloud-run//modules/v2
version: "~> 0.13.0"
version: ~> 0.13.0
spec:
outputExpr: service_account_id
- name: create_timeout
Expand Down Expand Up @@ -407,6 +407,12 @@ spec:
type:
- tuple
- []
- name: apphub_service_uri
description: Service URI in CAIS style to be used by Apphub.
type:
- object
- service_id: string
service_uri: string
- name: env_vars
description: Exported environment variables
type:
Expand Down Expand Up @@ -914,3 +920,12 @@ spec:
- serviceusage.googleapis.com
- sqladmin.googleapis.com
- workflows.googleapis.com
providerVersions:
- source: hashicorp/google
version: ">= 5.25, < 7"
- source: hashicorp/google-beta
version: ">= 5.25, < 7"
- source: hashicorp/null
version: ~> 3.1
- source: hashicorp/random
version: ~> 3.1
8 changes: 8 additions & 0 deletions modules/mysql/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,11 @@ output "env_vars" {
"CLOUD_SQL_DATABASE_NAME" : local.database_name
}
}

output "apphub_service_uri" {
value = {
service_uri = "//cloudsql.googleapis.com/projects${element(split("/projects", google_sql_database_instance.default.self_link), 1)}"
service_id = substr(format("%s-%s", var.name, md5(var.project_id)), 0, 63)
}
description = "Service URI in CAIS style to be used by Apphub."
}
1 change: 1 addition & 0 deletions modules/postgresql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ module "pg" {
| Name | Description |
|------|-------------|
| additional\_users | List of maps of additional users and passwords |
| apphub\_service\_uri | Service URI in CAIS style to be used by Apphub. |
| dns\_name | DNS name of the instance endpoint |
| env\_vars | Exported environment variables |
| generated\_user\_password | The auto generated default user password if not input password was provided |
Expand Down
21 changes: 18 additions & 3 deletions modules/postgresql/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ spec:
connections:
- source:
source: github.com/terraform-google-modules/terraform-google-network//modules/vpc
version: "~> 9.1.0"
version: ~> 9.1.0
spec:
outputExpr: network_id
inputPath: private_network
Expand Down Expand Up @@ -319,12 +319,12 @@ spec:
connections:
- source:
source: github.com/terraform-google-modules/terraform-google-service-accounts//modules/simple-sa
version: "~> 4.3.0"
version: ~> 4.3.0
spec:
outputExpr: id
- source:
source: github.com/GoogleCloudPlatform/terraform-google-cloud-run//modules/v2
version: "~> 0.13.0"
version: ~> 0.13.0
spec:
outputExpr: service_account_id
- name: create_timeout
Expand Down Expand Up @@ -397,6 +397,12 @@ spec:
type:
- tuple
- []
- name: apphub_service_uri
description: Service URI in CAIS style to be used by Apphub.
type:
- object
- service_id: string
service_uri: string
- name: dns_name
description: DNS name of the instance endpoint
type: string
Expand Down Expand Up @@ -904,3 +910,12 @@ spec:
- serviceusage.googleapis.com
- sqladmin.googleapis.com
- workflows.googleapis.com
providerVersions:
- source: hashicorp/google
version: ">= 5.25, < 7"
- source: hashicorp/google-beta
version: ">= 5.25, < 7"
- source: hashicorp/null
version: ~> 3.1
- source: hashicorp/random
version: ~> 3.1
8 changes: 8 additions & 0 deletions modules/postgresql/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,11 @@ output "env_vars" {
"CLOUD_SQL_DATABASE_NAME" : local.database_name
}
}

output "apphub_service_uri" {
value = {
service_uri = "//cloudsql.googleapis.com/projects${element(split("/projects", google_sql_database_instance.default.self_link), 1)}"
service_id = substr(format("%s-%s", var.name, md5(var.project_id)), 0, 63)
}
description = "Service URI in CAIS style to be used by Apphub."
}

0 comments on commit 29d5099

Please sign in to comment.