Title / Description
Code data "google_compute_network" "default" { name = lookup(var.gke_network_main, "vpc_name") } resource "random_string" "db_password" { length = 16 special = false lower = true upper = true } resource "google_sql_database_instance" "petstore" { count = contains(["dev", "prod"], local.envs) ? 1 : 0 name = "petstore" database_version = "POSTGRES_14" region = local.us-region settings { tier = "db-custom-4-32768" availability_type = local.envs != "prod" ? "ZONAL" : "REGIONAL" disk_autoresize = true disk_type = "PD_SSD" insights_config { record_application_tags = false record_client_address = false query_insights_enabled = true query_string_length = 1024 } database_flags { name = "cloudsql.enable_pg_cron" value = "on" } backup_configuration { enabled = true location = local.us-region point_in_time_recovery_enabled = true transaction_log_retention_days = 1 backup_retention_settings { retained_backups = 7 } } ip_configuration { ipv4_enabled = false private_network = data.google_compute_network.default.id } } } resource "google_sql_database" "petstore_db" { count = contains(["dev", "prod"], local.envs) ? 1 : 0 name = "petstore-db" instance = google_sql_database_instance.petstore.0.name } resource "google_sql_user" "petstore_user" { count = contains(["dev", "prod"], local.envs) ? 1 : 0 name = "petstore-user" instance = google_sql_database_instance.petstore.0.name password = random_string.db_password.result } resource "kubernetes_namespace" "petstore" { provider = kubernetes.gke metadata { name = "petstore" } } resource "random_uuid" "uuid" { } resource "kubernetes_secret" "session_secret" { provider = kubernetes.gke metadata { name = "session-secret" namespace = kubernetes_namespace.petstore.metadata[0].name } data = { key = replace(random_uuid.uuid.result, "-", "") } type = "Opaque" } resource "kubernetes_secret" "sql" { provider = kubernetes.gke count = contains(["dev", "prod"], local.envs) ? 1 : 0 metadata { name = "petstore-db-credentials" namespace = kubernetes_namespace.petstore.metadata[0].name } data = { DB_USERNAME = google_sql_user.petstore_user.0.name DB_PASSWORD = google_sql_user.petstore_user.0.password DB_IP = google_sql_database_instance.petstore.0.private_ip_address DB_NAME = google_sql_database.petstore_db.0.name } type = "Opaque" } resource "google_storage_bucket" "petstore_artifacts" { name = "petstore-artifacts-${local.envs}" location = "US" force_destroy = true } locals { envs = var.envs us-region = "us-central1" gke = data.terraform_remote_state.core.outputs.gke }
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code