#!/usr/bin/env bash # infrastructure/99-region-guard.sh — Regional availability intelligence # Sourced by other infrastructure scripts to ensure regional compliance. # --- 1. Known Regional Capabilities (v1beta1) --- # Vertex AI RAG Engine (Serverless) availability # Source: https://cloud.google.com/vertex-ai/docs/generative-ai/rag-overview RAG_SUPPORTED_REGIONS=("us-central1" "us-east1" "us-east4" "europe-west1" "europe-west4" "europe-west9" "asia-northeast1") # Vertex AI Agent Engine (Memory Bank / Reasoning Engine) availability # Most Vertex AI regions support this, but we track primary ones. AGENT_ENGINE_SUPPORTED_REGIONS=("us-central1" "europe-west4") # Cloud Run # Virtually all regions support Cloud Run, but we prefer those with low latency or specific compliance. # Default for OSVauco is us-central1 (Management Plane). # Default for clinical data is europe-north1. # --- 2. Helper Functions --- # Check if a value is in an array contains_element() { local e match="$1" shift for e; do [[ "$e" == "$match" ]] && return 0; done return 1 } # Validate RAG region validate_rag_region() { local TARGET_REGION="${1:-us-central1}" if contains_element "$TARGET_REGION" "${RAG_SUPPORTED_REGIONS[@]}"; then echo "$TARGET_REGION" else # Fallback to a safe region known to support serverless RAG echo "europe-west4" fi } # Validate Agent Engine region validate_agent_engine_region() { local TARGET_REGION="${1:-us-central1}" if contains_element "$TARGET_REGION" "${AGENT_ENGINE_SUPPORTED_REGIONS[@]}"; then echo "$TARGET_REGION" else # Fallback echo "us-central1" fi } # Log regional context log_region_context() { local SVC=$1 local REGION=$2 local STATUS=$3 echo -e " [REGION-GUARD] Service: ${SVC} | Region: ${REGION} | Status: ${STATUS}" }