Skip to content

Instantly share code, notes, and snippets.

@huogerac
Created August 18, 2023 19:18
Show Gist options
  • Save huogerac/5f191d2872513b94cc960fefc0d20c10 to your computer and use it in GitHub Desktop.
Save huogerac/5f191d2872513b94cc960fefc0d20c10 to your computer and use it in GitHub Desktop.
terraform_gcp_postgres
resource "random_integer" "postgres_port" {
min = 5432
max = 5432
}
resource "google_sql_database_instance" "postgres" {
name = "${var.environment}-postgres"
database_version = var.engine_version
deletion_protection = var.deletion_protection
# root_password = "${var.db_userpassword}"
settings {
tier = var.instance_class
ip_configuration {
ipv4_enabled = false
# private_network = "projects/${var.project}/global/networks/default"
enable_private_path_for_google_cloud_services = true
require_ssl = true
}
database_flags {
name = "cloudsql.logical_decoding"
value = "on"
}
}
timeouts {
create = "60m"
}
}
resource "google_sql_database" "database" {
name = var.db_name
instance = "${google_sql_database_instance.postgres.name}"
# charset = "utf8"
# collation = "utf8_general_ci"
}
resource "google_sql_user" "db_user" {
name = "${var.db_username}"
instance = "${google_sql_database_instance.postgres.name}"
password = "${var.db_userpassword}"
# host = "%"
}
@huogerac
Copy link
Author

Na linha 19 é onde eu preciso de alguma forma pegar o ip da instancia...
Me parece que preciso criar um data "alguma_coisa" que tenha isto

Alguém já fez isto?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment