feat(C2): customer stamp-out struktur og create_customer.sh
- customers/_template/ med main.tf, variables.tf, terraform.tfvars - customers/medioteq/ populert med produksjonsverdier - infrastructure/scripts/create_customer.sh for stamp-out av nye kunder - .gitignore: unntak for customers/**/*.tfvars
This commit is contained in:
parent
fbdbf14552
commit
a807b0dd89
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -47,3 +47,4 @@ Thumbs.db
|
||||||
tfplan.txt
|
tfplan.txt
|
||||||
infrastructure/terraform/tfplan
|
infrastructure/terraform/tfplan
|
||||||
**/tfplan
|
**/tfplan
|
||||||
|
!infrastructure/terraform/customers/**/*.tfvars
|
||||||
|
|
|
||||||
40
infrastructure/scripts/create_customer.sh
Executable file
40
infrastructure/scripts/create_customer.sh
Executable file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [ -z "${1-}" ]; then
|
||||||
|
echo "Usage: $0 <customer_name>" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
CUSTOMER_NAME=$1
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
CUSTOMER_DIR="${SCRIPT_DIR}/../terraform/customers/${CUSTOMER_NAME}"
|
||||||
|
TEMPLATE_DIR="${SCRIPT_DIR}/../terraform/customers/_template"
|
||||||
|
|
||||||
|
if [ -d "${CUSTOMER_DIR}" ]; then
|
||||||
|
echo "Error: Customer directory already exists: ${CUSTOMER_DIR}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp -r "${TEMPLATE_DIR}" "${CUSTOMER_DIR}"
|
||||||
|
echo "✓ Directory created: ${CUSTOMER_DIR}"
|
||||||
|
|
||||||
|
read -p "GCP Project ID (e.g., ${CUSTOMER_NAME}-prod-eun1): " PROJECT_ID
|
||||||
|
read -p "GCP Billing Account ID: " BILLING_ACCOUNT_ID
|
||||||
|
read -p "Alert Email: " ALERT_EMAIL
|
||||||
|
read -p "Container Image URI: " CONTAINER_IMAGE
|
||||||
|
|
||||||
|
cat > "${CUSTOMER_DIR}/terraform.tfvars" << EOF
|
||||||
|
customer_id = "${CUSTOMER_NAME}"
|
||||||
|
project_id = "${PROJECT_ID}"
|
||||||
|
region = "europe-north1"
|
||||||
|
billing_account_id = "${BILLING_ACCOUNT_ID}"
|
||||||
|
alert_email = "${ALERT_EMAIL}"
|
||||||
|
billing_viewer_emails = ["chris.christiansen@vauco.no"]
|
||||||
|
container_image = "${CONTAINER_IMAGE}"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "✓ terraform.tfvars created."
|
||||||
|
terraform -chdir="${CUSTOMER_DIR}" init
|
||||||
|
terraform -chdir="${CUSTOMER_DIR}" apply -auto-approve
|
||||||
|
echo "=== Customer ${CUSTOMER_NAME} created successfully! ==="
|
||||||
24
infrastructure/terraform/customers/_template/main.tf
Normal file
24
infrastructure/terraform/customers/_template/main.tf
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
google = {
|
||||||
|
source = "hashicorp/google"
|
||||||
|
version = "~> 5.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "google" {
|
||||||
|
project = var.project_id
|
||||||
|
}
|
||||||
|
|
||||||
|
module "customer" {
|
||||||
|
source = "../../modules/vauco-bootstrap"
|
||||||
|
|
||||||
|
customer_id = var.customer_id
|
||||||
|
project_id = var.project_id
|
||||||
|
region = var.region
|
||||||
|
billing_account_id = var.billing_account_id
|
||||||
|
alert_email = var.alert_email
|
||||||
|
billing_viewer_emails = var.billing_viewer_emails
|
||||||
|
container_image = var.container_image
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
customer_id = ""
|
||||||
|
project_id = ""
|
||||||
|
region = "europe-north1"
|
||||||
|
billing_account_id = ""
|
||||||
|
alert_email = ""
|
||||||
|
billing_viewer_emails = []
|
||||||
|
container_image = ""
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
variable "customer_id" { type = string }
|
||||||
|
variable "project_id" { type = string }
|
||||||
|
variable "region" { type = string }
|
||||||
|
variable "billing_account_id" { type = string }
|
||||||
|
variable "alert_email" { type = string }
|
||||||
|
variable "billing_viewer_emails" { type = list(string) }
|
||||||
|
variable "container_image" { type = string }
|
||||||
24
infrastructure/terraform/customers/medioteq/main.tf
Normal file
24
infrastructure/terraform/customers/medioteq/main.tf
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
google = {
|
||||||
|
source = "hashicorp/google"
|
||||||
|
version = "~> 5.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "google" {
|
||||||
|
project = var.project_id
|
||||||
|
}
|
||||||
|
|
||||||
|
module "customer" {
|
||||||
|
source = "../../modules/vauco-bootstrap"
|
||||||
|
|
||||||
|
customer_id = var.customer_id
|
||||||
|
project_id = var.project_id
|
||||||
|
region = var.region
|
||||||
|
billing_account_id = var.billing_account_id
|
||||||
|
alert_email = var.alert_email
|
||||||
|
billing_viewer_emails = var.billing_viewer_emails
|
||||||
|
container_image = var.container_image
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
customer_id = "medioteq"
|
||||||
|
project_id = "medioteq-prod-eun1"
|
||||||
|
region = "europe-north1"
|
||||||
|
billing_account_id = "0171F6-057E6B-A260BA"
|
||||||
|
alert_email = "billing@vauco.no"
|
||||||
|
billing_viewer_emails = ["chris.christiansen@vauco.no", "jason.vauger@vauco.no"]
|
||||||
|
container_image = "europe-north1-docker.pkg.dev/medioteq-prod-eun1/agent-images/osvauco-agent:latest"
|
||||||
7
infrastructure/terraform/customers/medioteq/variables.tf
Normal file
7
infrastructure/terraform/customers/medioteq/variables.tf
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
variable "customer_id" { type = string }
|
||||||
|
variable "project_id" { type = string }
|
||||||
|
variable "region" { type = string }
|
||||||
|
variable "billing_account_id" { type = string }
|
||||||
|
variable "alert_email" { type = string }
|
||||||
|
variable "billing_viewer_emails" { type = list(string) }
|
||||||
|
variable "container_image" { type = string }
|
||||||
Loading…
Reference in New Issue
Block a user