Files
smom-dbis-138/scripts/terraform/import-existing-rgs.sh
defiQUG 1fb7266469 Add Oracle Aggregator and CCIP Integration
- Introduced Aggregator.sol for Chainlink-compatible oracle functionality, including round-based updates and access control.
- Added OracleWithCCIP.sol to extend Aggregator with CCIP cross-chain messaging capabilities.
- Created .gitmodules to include OpenZeppelin contracts as a submodule.
- Developed a comprehensive deployment guide in NEXT_STEPS_COMPLETE_GUIDE.md for Phase 2 and smart contract deployment.
- Implemented Vite configuration for the orchestration portal, supporting both Vue and React frameworks.
- Added server-side logic for the Multi-Cloud Orchestration Portal, including API endpoints for environment management and monitoring.
- Created scripts for resource import and usage validation across non-US regions.
- Added tests for CCIP error handling and integration to ensure robust functionality.
- Included various new files and directories for the orchestration portal and deployment scripts.
2025-12-12 14:57:48 -08:00

53 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Helper script to generate terraform import commands for existing resource groups
# that match the global multi-region naming convention.
#
# This is a dry-run helper: it only PRINTS terraform import commands.
# Review them and run manually as needed.
#
# Usage:
# scripts/terraform/import-existing-rgs.sh
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
TERRAFORM_DIR="$PROJECT_ROOT/terraform"
cd "$TERRAFORM_DIR"
echo "Discovering existing Azure resource groups matching pattern 'az-p-*-rg-comp-001'..."
RG_LIST="$(az group list --query "[?contains(name, '-rg-comp-001')].name" -o tsv || true)"
if [[ -z "$RG_LIST" ]]; then
echo "No matching resource groups found."
exit 0
fi
echo
echo "Existing compute resource groups:"
echo "$RG_LIST"
echo
echo "Proposed terraform import commands:"
echo
while IFS= read -r RG; do
# Example name: az-p-nor-rg-comp-001
# Extract region code (3rd dash-separated segment)
REGION_CODE="$(echo "$RG" | awk -F'-' '{print $3}')"
# Map region code to region name via locals.tf region_codes (best effort)
REGION_NAME="$(grep -E "^[[:space:]]*${REGION_CODE}[[:space:]]*=" locals.tf 2>/dev/null | awk -F'=' '{print $1}' | tr -d '[:space:]' || true)"
echo "# Resource group: ${RG}"
echo "# Region code guess: ${REGION_CODE} Region name key: ${REGION_NAME:-<unknown>}"
echo "terraform import 'azurerm_resource_group.global_multi_region[\"${REGION_NAME:-<region-key>}\"]' \"/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/${RG}\""
echo
done <<< "$RG_LIST"
echo "NOTE: Replace <SUBSCRIPTION_ID> and <region-key> as appropriate before running imports."