OSVauco/infrastructure/scripts/create_customer.sh
Chris Christiansen 9fcb9c354a
Some checks are pending
Check Python Version Consistency / Check Python Version (push) Waiting to run
feat(core): Fresh initialization - Deploy v3.6.1 Singularity Architecture
2026-09-03 04:03:09 +00:00

41 lines
1.3 KiB
Bash
Executable File

#!/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! ==="