feat(terraform): add vauco-platform module with domain mappings + CG3 variables
This commit is contained in:
parent
cb9a887f1d
commit
7b95705c07
91
infrastructure/terraform/modules/vauco-platform/main.tf
Normal file
91
infrastructure/terraform/modules/vauco-platform/main.tf
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
# ==============================================================================
|
||||
# vauco-platform — Vauco sin egen plattforminfrastruktur
|
||||
# Scope: propane-will-491900-m5 / europe-west1
|
||||
# Håndterer: Cloud Run domain mappings, salgsmodul-subdomener
|
||||
# ==============================================================================
|
||||
|
||||
locals {
|
||||
labels = {
|
||||
managed-by = "terraform"
|
||||
team = "vauco"
|
||||
environment = "prod"
|
||||
}
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Eksisterende Cloud Run-service (data source — ikke opprettet av Terraform)
|
||||
# ------------------------------------------------------------------------------
|
||||
data "google_cloud_run_service" "platform" {
|
||||
name = var.cloud_run_service_name
|
||||
location = var.region
|
||||
project = var.project_id
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Domain mapping — opax.vauco.no (primær)
|
||||
# ------------------------------------------------------------------------------
|
||||
resource "google_cloud_run_domain_mapping" "opax" {
|
||||
name = "opax.vauco.no"
|
||||
location = var.region
|
||||
project = var.project_id
|
||||
|
||||
metadata {
|
||||
namespace = var.project_id
|
||||
labels = local.labels
|
||||
}
|
||||
|
||||
spec {
|
||||
route_name = data.google_cloud_run_service.platform.name
|
||||
certificate_mode = "AUTOMATIC"
|
||||
force_override = false
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
# Ikke slett mappingen ved rename — Cloud Run domain mappings er sårbare
|
||||
prevent_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Domain mapping — costguard.oss.vauco.no (CG3 — salgsmodul)
|
||||
# ------------------------------------------------------------------------------
|
||||
resource "google_cloud_run_domain_mapping" "costguard_oss" {
|
||||
name = var.costguard_domain
|
||||
location = var.region
|
||||
project = var.project_id
|
||||
|
||||
metadata {
|
||||
namespace = var.project_id
|
||||
labels = merge(local.labels, { module = "costguard" })
|
||||
}
|
||||
|
||||
spec {
|
||||
route_name = data.google_cloud_run_service.platform.name
|
||||
certificate_mode = "AUTOMATIC"
|
||||
force_override = false
|
||||
}
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Domain mapping — dynamisk per salgsmodul
|
||||
# Brukes når nye moduler legges til i var.salesmodule_domains
|
||||
# Eks: ["threadstone.oss.vauco.no", "invoicepilot.oss.vauco.no"]
|
||||
# ------------------------------------------------------------------------------
|
||||
resource "google_cloud_run_domain_mapping" "salesmodules" {
|
||||
for_each = toset(var.salesmodule_domains)
|
||||
|
||||
name = each.value
|
||||
location = var.region
|
||||
project = var.project_id
|
||||
|
||||
metadata {
|
||||
namespace = var.project_id
|
||||
labels = merge(local.labels, { module = split(".", each.value)[0] })
|
||||
}
|
||||
|
||||
spec {
|
||||
route_name = data.google_cloud_run_service.platform.name
|
||||
certificate_mode = "AUTOMATIC"
|
||||
force_override = false
|
||||
}
|
||||
}
|
||||
19
infrastructure/terraform/modules/vauco-platform/outputs.tf
Normal file
19
infrastructure/terraform/modules/vauco-platform/outputs.tf
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
output "opax_domain" {
|
||||
description = "OPAX operator hub URL"
|
||||
value = "https://${google_cloud_run_domain_mapping.opax.name}"
|
||||
}
|
||||
|
||||
output "costguard_domain" {
|
||||
description = "CostGuard salgsmodul URL"
|
||||
value = "https://${google_cloud_run_domain_mapping.costguard_oss.name}"
|
||||
}
|
||||
|
||||
output "salesmodule_domains" {
|
||||
description = "Alle aktive salgsmodul-URLer"
|
||||
value = { for k, v in google_cloud_run_domain_mapping.salesmodules : k => "https://${v.name}" }
|
||||
}
|
||||
|
||||
output "cloud_run_service_name" {
|
||||
description = "Cloud Run-service alle domener peker på"
|
||||
value = data.google_cloud_run_service.platform.name
|
||||
}
|
||||
30
infrastructure/terraform/modules/vauco-platform/variables.tf
Normal file
30
infrastructure/terraform/modules/vauco-platform/variables.tf
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
variable "project_id" {
|
||||
description = "Vauco platform GCP project ID"
|
||||
type = string
|
||||
default = "propane-will-491900-m5"
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
description = "Cloud Run region"
|
||||
type = string
|
||||
default = "europe-west1"
|
||||
}
|
||||
|
||||
variable "cloud_run_service_name" {
|
||||
description = "Navn på eksisterende Cloud Run-service"
|
||||
type = string
|
||||
default = "osvauco-agent"
|
||||
}
|
||||
|
||||
variable "costguard_domain" {
|
||||
description = "Primærdomene for CostGuard salgsmodul"
|
||||
type = string
|
||||
default = "costguard.oss.vauco.no"
|
||||
}
|
||||
|
||||
variable "salesmodule_domains" {
|
||||
description = "Liste over salgsmodul-subdomener som skal mappes til Cloud Run"
|
||||
type = list(string)
|
||||
default = []
|
||||
# Eksempel: ["threadstone.oss.vauco.no", "invoicepilot.oss.vauco.no"]
|
||||
}
|
||||
31
infrastructure/terraform/platform.tf
Normal file
31
infrastructure/terraform/platform.tf
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# ==============================================================================
|
||||
# platform.tf — Vauco sin egen plattform (propane-will-491900-m5)
|
||||
# Kjøres fra: infrastructure/terraform/
|
||||
# State: terraform.tfstate (samme workspace som vauco-bootstrap/medioteq)
|
||||
#
|
||||
# For å kjøre kun denne modulen:
|
||||
# terraform apply -target=module.vauco_platform
|
||||
# ==============================================================================
|
||||
|
||||
module "vauco_platform" {
|
||||
source = "./modules/vauco-platform"
|
||||
|
||||
project_id = "propane-will-491900-m5"
|
||||
region = "europe-west1"
|
||||
cloud_run_service_name = "osvauco-agent"
|
||||
costguard_domain = "costguard.oss.vauco.no"
|
||||
|
||||
# Legg til nye salgsmodul-subdomener her etter hvert:
|
||||
salesmodule_domains = [
|
||||
# "threadstone.oss.vauco.no",
|
||||
# "invoicepilot.oss.vauco.no",
|
||||
]
|
||||
}
|
||||
|
||||
output "platform_opax_url" {
|
||||
value = module.vauco_platform.opax_domain
|
||||
}
|
||||
|
||||
output "platform_costguard_url" {
|
||||
value = module.vauco_platform.costguard_domain
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user