GitHub

LaunchBot

A CLI tool for automating infrastructure configuration generation for the healthAlignPMS platform across Azure, GCP, and Cloudflare.

Overview

LaunchBot streamlines the creation and management of multi-cloud infrastructure configurations for healthAlignPMS tenants. It automates the generation of Terraform configurations, Azure DevOps pipelines, deployment configurations, and database seeding operations. The tool integrates seamlessly with the Zig build system and automatically extracts configuration values from Terraform state, reducing manual input and preventing configuration errors.

Installation

Build

./zig/zig build launchbot

The compiled binary will be available as ./launchbot in the project root.

Usage

Main Commands

LaunchBot provides two main command groups:

launchbot generate [subcommand]  # Generate infrastructure configurations

Global Flags

Flag Short Description
--verbose -v Enable verbose output
--quiet -q Suppress non-error output
--help -h Display help information

Generate Commands

1. Generate Tenant Configuration

Creates Terraform configuration files for a new healthAlignPMS tenant.

Command Structure

launchbot generate tenant [--flags]

Parameters

Flag Short Required Description
--tenant -t Tenant key identifier (e.g., aarp, bcbs-az, humana)
--environment -e Environment: staging or production
--cluster-name Cluster name to use for the tenant

Note: All flags are optional. If not provided, the command runs in interactive mode with guided prompts.

Examples

# Interactive mode with guided prompts
launchbot generate tenant

# CLI mode with all flags
launchbot generate tenant --tenant aarp --environment staging --cluster-name THB-N-WEB1

# Short flags
launchbot generate tenant -t bcbs-az -e production --cluster-name THB-P-WEB1

2. Generate Azure DevOps Pipelines

Generates Azure DevOps release definitions for database, web app, and interface task deployments. Automatically extracts configuration from Terraform output.

Command Structure

launchbot generate azure_devops --tenant [TENANT] --environment [ENV]

Parameters

Flag Short Required Description
--tenant -t Tenant key identifier (e.g., aarp, bcbs-az)
--environment -e Environment: staging or production

What Gets Generated

  • Database Release Pipeline - Deploys and applies database migrations
  • Web App Release Pipeline - Deploys the main web application
  • Interface Task Release Pipeline - Deploys background task services

Examples

# Generate all three release pipelines for AARP staging
./launchbot generate azure_devops --tenant aarp --environment staging

# Generate pipelines for BCBS-AZ production (short flags)
./launchbot generate azure_devops -t bcbs-az -e production

How It Works

  1. Runs ./zig/zig build output -- ha-infra to get Terraform state
  2. Extracts tenant-specific values:
    • Tenant name and client ID
    • Domain and Cloudflare tunnel secrets
    • Azure DevOps queue and deployment group IDs
    • SSH connection IDs for Linux and Windows VMs
  3. Generates three Azure DevOps release definitions
  4. Automatically deploys the database pipeline (required before seeding)

3. Generate Deployment Configuration

Generates complete deployment configuration files for a tenant including environment variables, Caddyfile, Cloudflared config, and IdentityServer settings.

Command Structure

launchbot generate deploy_config --tenant [TENANT] --environment [ENV] [--optional-flags]

Parameters

Flag Short Required Description
--tenant -t ✅* Tenant key identifier (e.g., aarp, bcbs-az)
--environment -e ✅* Environment: staging or production
--url -u Admin URL (auto-extracted from Terraform if not provided)
--database -d Database name (auto-extracted from Terraform if not provided)
--tunnel -T Cloudflare tunnel ID (auto-extracted from Terraform if not provided)
--client-id -c Client ID (auto-extracted from Terraform if not provided)
--force -f Force overwrite existing files without prompting

*Required only for CLI mode. Interactive mode requires no flags.

Auto-Extraction Feature 🤖

The deploy_config command automatically extracts missing values from Terraform output:

  1. Runs ./zig/zig build output -- ha-infra [environment]
  2. Extracts from Terraform state:
    • URL - Constructed from apps.[tenant].domains[0]
    • Database - Extracted from apps.[tenant].db_resource_name
    • Tunnel ID - Looked up via cloudflare_tunnel_ids.[domain]
    • Client ID - Extracted from apps.[tenant].client_id

What Gets Generated

The command creates configuration files in the healthAlignPMS repository:

  • .envs/.[tenant]-[env]/ - Application environment variables
  • .caddy/.[tenant]-[env]/Caddyfile - Caddy reverse proxy configuration
  • .cloudflared/.[tenant]-[env]/config.yml - Cloudflare tunnel configuration
  • .envs/.identityserver-[env]/ - IdentityServer client configuration

Examples

# Interactive mode - prompts for all values
launchbot generate deploy_config

# Auto-extraction mode (RECOMMENDED) - only requires tenant and environment
launchbot generate deploy_config --tenant demo --environment staging

# Override specific auto-extracted values
launchbot generate deploy_config --tenant demo --environment staging \
  --url https://custom.domain.com/ \
  --database customDB

# Manual mode - provide all values explicitly
launchbot generate deploy_config \
  --tenant aarp \
  --url https://aarp.myhaapp.com/ \
  --database hAAARP \
  --environment production \
  --tunnel 50ef9e33-a613-4159-9624-08c6963ec73f \
  --client-id 9

# Force overwrite existing files
launchbot generate deploy_config --tenant demo --environment staging --force

Environment Mapping

The tool automatically maps user-friendly environment names to Terraform environment names:

User Input Terraform Environment
staging, uat non-production
production, prod production
development, dev development

Pull Request Creation

After generating configurations, LaunchBot offers to create a pull request in the healthAlignPMS repository:

  • Creates a feature branch: feat/deploy_config-[tenant]-[environment]
  • Commits all generated files
  • Pushes to origin
  • Creates PR targeting release branch

Seed Commands

Seed Databases

Seeds a target database with initial data from a source database.

Command Structure

launchbot seed databases --environment [ENV] --database [DB_NAME]

Parameters

Flag Short Required Description
--environment -e Environment: staging or production
--database -d Target database name (e.g., hADemo, hAUAT_Test)

Examples

# Seed a production database
./launchbot seed databases --environment production --database hADemo

# Seed a staging database (short flags)
./launchbot seed databases -e staging -d hAUAT_Test

Seed App Records

Creates Identity Server app records for a tenant in the Tenants.Apps table. This command automatically extracts the admin portal URL and client ID from Terraform output.

Command Structure

launchbot seed app_records --tenant [TENANT] --environment [ENV]

Parameters

Flag Short Required Description
--tenant -t Tenant key identifier (e.g., aarp, bcbs-az)
--environment -e Environment: staging or production

Prerequisites

  • Terraform infrastructure must be deployed (./zig/zig build apply)
  • Client records must exist (run create_client_records.sh or generate tenant first)

Examples

# Seed app records for a tenant in staging
./launchbot seed app_records --tenant aarp --environment staging

# Seed app records in production
./launchbot seed app_records --tenant bcbs-az --environment production

# Short flag version
./launchbot seed app_records -t bcbs-az -e production

How It Works

  1. Connects to the Azure SQL Database for the specified environment
  2. Runs ./zig/zig build output to get Terraform state
  3. Extracts admin URL from apps.[tenant].domains[0]
  4. Extracts or queries client ID
  5. Creates record in Tenants.Apps table (skips if already exists)

Seed Consumer Portal Config

Seeds consumer portal configuration for a tenant in the ConsumerPortalConfig table. This command creates or updates the consumer portal URL for the specified tenant.

Command Structure

launchbot seed consumer_portal_config --tenant [TENANT] --environment [ENV] --url [URL]

Parameters

Flag Short Required Description
--tenant -t Tenant key identifier (e.g., aarp, bcbs-az)
--environment -e Environment: staging or production
--url -u Consumer portal URL (must end with /)

Prerequisites

  • Client records must exist (run create_client_records.sh or generate tenant first)
  • Consumer portal URL must be provided and cannot be a placeholder

Examples

# Seed consumer portal config for a tenant in staging
./launchbot seed consumer_portal_config --tenant aarp --environment staging --url https://consumer.aarp.example.com/

# Seed consumer portal config in production
./launchbot seed consumer_portal_config --tenant bcbs-az --environment production --url https://portal.bcbs-az.com/

# Short flag version
./launchbot seed consumer_portal_config -t bcbs-az -e production -u https://portal.bcbs-az.com/

Validation

  • URL cannot be empty or a placeholder value
  • URL must end with a forward slash (/)

How It Works

  1. Validates the consumer portal URL
  2. Connects to the Azure SQL Database for the specified environment
  3. Runs ./zig/zig build output to get Terraform state (or queries database for client ID)
  4. Creates or updates record in ConsumerPortalConfig table

Common Workflows

Complete New Tenant Setup

Follow these steps to fully provision a new tenant:

# Step 1: Generate Terraform configuration
launchbot generate tenant --tenant newclient --environment staging --cluster-name THB-N-WEB1

# Step 2: Review and apply Terraform changes
./zig/zig build plan -- non-production
./zig/zig build apply -- non-production  # Dev environment only

# Step 3: Generate Azure DevOps pipelines
launchbot generate azure_devops --tenant newclient --environment staging

# Step 4: Generate deployment configurations
launchbot generate deploy_config --tenant newclient --environment staging

# Step 5: Seed the database
launchbot seed databases --environment staging --database hANewClientUAT

Update Existing Tenant Configuration

# Regenerate deployment configs with auto-extraction
launchbot generate deploy_config --tenant existingclient --environment production --force

# The --force flag skips the overwrite confirmation prompt

Quick Azure DevOps Pipeline Setup

# Generate all release pipelines in one command
launchbot generate azure_devops -t demo -e staging

Error Handling

Common Issues

Missing Database Configuration

failed to extract database name: tenant 'aarp' does not have a database configured
  • Solution: Some tenants may not have dedicated databases. Provide the --database flag manually or skip database-dependent operations.

Terraform Output Not Found

failed to get terraform output: environment 'staging' not found
  • Solution: Ensure Terraform has been applied for the target environment: ./zig/zig build apply -- non-production

Azure DevOps Permission Denied

failed to run ado command: permission denied
  • Solution: Ensure you have ADO CLI installed and authenticated. Run ./zig/zig build ado to install.