Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
simonebruzzechesse committed May 17, 2024
1 parent 29b4a08 commit 9c1fc95
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 3 additions & 1 deletion modules/alloydb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,7 @@ module "alloydb" {
| [ips](outputs.tf#L49) | IP addresses of all instances. | |
| [name](outputs.tf#L56) | Name of the primary instance. | |
| [names](outputs.tf#L61) | Names of all instances. | |
| [user_passwords](outputs.tf#L69) | Map of containing the password of all users created through terraform. ||
| [secondary_id](outputs.tf#L69) | Fully qualified primary instance id. | |
| [secondary_ip](outputs.tf#L74) | IP address of the primary instance. | |
| [user_passwords](outputs.tf#L79) | Map of containing the password of all users created through terraform. ||
<!-- END TFDOC -->
4 changes: 2 additions & 2 deletions modules/alloydb/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ resource "google_alloydb_cluster" "secondary" {

resource "google_alloydb_instance" "secondary" {
count = var.cross_region_replication.enabled ? 1 : 0
cluster = google_alloydb_cluster.secondary.0.id
cluster = google_alloydb_cluster.secondary[0].id
instance_id = "${local.prefix}${var.name}-secondary"
instance_type = google_alloydb_cluster.secondary.0.cluster_type
instance_type = google_alloydb_cluster.secondary[0].cluster_type
availability_type = var.availability_type
database_flags = var.flags
display_name = "${local.prefix}${var.name}"
Expand Down
12 changes: 11 additions & 1 deletion modules/alloydb/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ locals {
# { primary = google_alloydb_instance.primary },
# google_alloydb_instance.replicas
# )
_all_instances = { primary = google_alloydb_instance.primary }
_all_instances = merge({ primary = google_alloydb_instance.primary }, var.cross_region_replication.enabled ? { secondary = google_alloydb_instance.secondary[0] } : {})
}

output "id" {
Expand Down Expand Up @@ -66,6 +66,16 @@ output "names" {
}
}

output "secondary_id" {
description = "Fully qualified primary instance id."
value = var.cross_region_replication.enabled ? google_alloydb_instance.secondary.id : null
}

output "secondary_ip" {
description = "IP address of the primary instance."
value = var.cross_region_replication.enabled ? google_alloydb_instance.secondary.ip_address : null
}

output "user_passwords" {
description = "Map of containing the password of all users created through terraform."
value = {
Expand Down

0 comments on commit 9c1fc95

Please sign in to comment.