diff --git a/.gitignore b/.gitignore index 9a744cf..46a3886 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ Thumbs.db tfplan.txt infrastructure/terraform/tfplan **/tfplan +!infrastructure/terraform/customers/**/*.tfvars diff --git a/infrastructure/scripts/create_customer.sh b/infrastructure/scripts/create_customer.sh new file mode 100755 index 0000000..9b16646 --- /dev/null +++ b/infrastructure/scripts/create_customer.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ -z "${1-}" ]; then + echo "Usage: $0 " >&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! ===" diff --git a/infrastructure/terraform/customers/_template/main.tf b/infrastructure/terraform/customers/_template/main.tf new file mode 100644 index 0000000..3806428 --- /dev/null +++ b/infrastructure/terraform/customers/_template/main.tf @@ -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 +} diff --git a/infrastructure/terraform/customers/_template/terraform.tfvars b/infrastructure/terraform/customers/_template/terraform.tfvars new file mode 100644 index 0000000..8466e3c --- /dev/null +++ b/infrastructure/terraform/customers/_template/terraform.tfvars @@ -0,0 +1,7 @@ +customer_id = "" +project_id = "" +region = "europe-north1" +billing_account_id = "" +alert_email = "" +billing_viewer_emails = [] +container_image = "" diff --git a/infrastructure/terraform/customers/_template/variables.tf b/infrastructure/terraform/customers/_template/variables.tf new file mode 100644 index 0000000..f6be3d8 --- /dev/null +++ b/infrastructure/terraform/customers/_template/variables.tf @@ -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 } diff --git a/infrastructure/terraform/customers/medioteq/main.tf b/infrastructure/terraform/customers/medioteq/main.tf new file mode 100644 index 0000000..3806428 --- /dev/null +++ b/infrastructure/terraform/customers/medioteq/main.tf @@ -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 +} diff --git a/infrastructure/terraform/customers/medioteq/terraform.tfvars b/infrastructure/terraform/customers/medioteq/terraform.tfvars new file mode 100644 index 0000000..ffde9c2 --- /dev/null +++ b/infrastructure/terraform/customers/medioteq/terraform.tfvars @@ -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" diff --git a/infrastructure/terraform/customers/medioteq/variables.tf b/infrastructure/terraform/customers/medioteq/variables.tf new file mode 100644 index 0000000..f6be3d8 --- /dev/null +++ b/infrastructure/terraform/customers/medioteq/variables.tf @@ -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 }