GoogleCloudPlatform/terraform-google-alloy-db

there is no output named by "private_ip_address" of alloydb instance to fetch

Closed this issue · 3 comments

Hi,
I was using this alloy-db module but seems like there is no output variable configured for private IP address of alloydb instance.
May I know any way to fetch it out in the same terraform configuration

@arpitgup try primary_instance.ip_address

appreciate your response
I have tried but its throwing error but I have figured some other way to fetch ip_address using gcloud command via null_executionor resource & call it out via output variable.

@arpitgup Just tested it and it works fine. Here is a sample code

module "alloy-db" {
  source               = "GoogleCloudPlatform/alloy-db/google"
  project_id           = "my-project-id"
  cluster_id           = "alloydb-cluster-with-primary-instance"
  cluster_location     = "us-central1"
  cluster_labels       = {}
  cluster_display_name = ""
  cluster_initial_user = {
    user     = "sdflkjdsfljs",
    password = "sfldjlkjdklsjklj2323"
  }
  network_self_link = "projects/my-project-id/global/networks/prefix-1-vpc"

  automated_backup_policy = null

  primary_instance = {
    instance_id       = "primary-instance",
    instance_type     = "PRIMARY",
    machine_cpu_count = 8,
    database_flags    = {},
    display_name      = "alloydb-primary-instance"
  }
  read_pool_instance = null
}

output "ip_address" {
  value = module.alloy-db.primary_instance.ip_address
}
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

ip_address = "10.9.0.214"