Establish Site to Site Connectivity with HA-VPN using NCC
Solution for Establish Site to Site Connectivity with HA-VPN using NCC. 1 lab: GSP1316. Fast copy-paste commands for Google Cloud.
GSP1316 — Establish Site to Site Connectivity with HA-VPN using NCC
Estimated time: 20 minutes
# 🌐 Site-to-Site Data Transfer with Network Connectivity Center > ⚠️ **Disclaimer:** This is an independent, community-made walkthrough created to help you understand why each step works. Attempt the challenge yourself first. This guide is provided for educational purposes and is not intended to replace the official lab instructions or your own hands-on learning. It is not affiliated with or endorsed by Google Cloud or Google Cloud Skills Boost. Always follow the official Google Cloud and Qwik
GREEN='\e[1;32m'
CYAN='\e[1;36m'
YELLOW='\e[1;33m'
BLUE='\e[1;34m'
MAGENTA='\e[1;35m'
WHITE='\e[1;37m'
RESET='\e[0m'
BOLD='\e[1m'
clear
echo -e "${CYAN}${BOLD}"
cat << "EOF"
____ _ _ _ __ ___
/ __ \ | | (_) | / _| / _ \
| | | |_ __| |__ _| |_ ___ | |_ | | | |_ __ ___
| | | | '__| '_ \| | __| / _ \ | _| | | | | '_ \/ __|
| |__| | | | |_) | | |_ | (_) || | | |_| | |_) \__ \
\____/|_| |_.__/|_|\__| \___/ |_| \___/| .__/|___/
| |
|_|
EOF
echo -e "${RESET}"
echo -e "${BLUE}${BOLD}╔════════════════════════════════════════════════════════════╗${RESET}"
echo -e "${BLUE}${BOLD}║ 🌊 WELCOME TO Orbit Of Ops ║${RESET}"
echo -e "${BLUE}${BOLD}║ 🚀 TARGET: GSP1316 SITE-TO-SITE DATA TRANSFER WITH NCC ║${RESET}"
echo -e "${BLUE}${BOLD}╚════════════════════════════════════════════════════════════╝${RESET}\n"
echo -e "${BOLD}${YELLOW}[Orbit of Ops] Auto-fetching Configurations...${RESET}"
export PROJECT_ID=$(gcloud config get-value project 2>/dev/null)
echo -e "✅ Project ID: ${GREEN}$PROJECT_ID${RESET}"
echo -e "${YELLOW}[*] Enabling Network Connectivity API...${RESET}"
gcloud services enable networkconnectivity.googleapis.com --quiet || true
# ==============================================================================
# STEP 1: GLOBAL DISCOVERY OF TUNNELS & REGIONS
# ==============================================================================
echo -e "\n${YELLOW}[*] Discovering VPN Tunnels across ALL regions...${RESET}"
ALL_TUNNELS=$(gcloud compute vpn-tunnels list --format="value(name, region.basename())")
# Extract Office 1 Tunnels (starting with 'routing') & their specific Region
O1_MATCHES=$(echo "$ALL_TUNNELS" | grep -iE '^routing.*office-?1')
T1_NAMES=$(echo "$O1_MATCHES" | awk '{print $1}' | paste -sd, -)
R1=$(echo "$O1_MATCHES" | awk '{print $2}' | head -n 1)
# Extract Office 2 Tunnels (starting with 'routing') & their specific Region
O2_MATCHES=$(echo "$ALL_TUNNELS" | grep -iE '^routing.*office-?2')
T2_NAMES=$(echo "$O2_MATCHES" | awk '{print $1}' | paste -sd, -)
R2=$(echo "$O2_MATCHES" | awk '{print $2}' | head -n 1)
echo -e "✅ Office 1 Region detected: ${CYAN}$R1${RESET}"
echo -e "✅ Office 1 Tunnels found: ${CYAN}$T1_NAMES${RESET}\n"
echo -e "✅ Office 2 Region detected: ${CYAN}$R2${RESET}"
echo -e "✅ Office 2 Tunnels found: ${CYAN}$T2_NAMES${RESET}\n"
# ==============================================================================
# STEP 2: CLEANUP OF PARTIAL STATE
# ==============================================================================
echo -e "${YELLOW}[*] Enforcing clean state (removing old spokes if they exist)...${RESET}"
gcloud network-connectivity spokes delete office-1-spoke --region=$R1 --quiet 2>/dev/null || true
gcloud network-connectivity spokes delete office-2-spoke --region=$R2 --quiet 2>/dev/null || true
# ==============================================================================
# TASK 1: CREATE NCC HUB
# ==============================================================================
echo -e "\n${GREEN}${BOLD}▬▬▬▬▬▬ TASK 1: CREATE NCC HUB ▬▬▬▬▬▬${RESET}"
gcloud network-connectivity hubs create ncc-hub --quiet 2>/dev/null || echo -e "✅ Hub 'ncc-hub' already exists, proceeding..."
# ==============================================================================
# TASK 2: DEFINE SPOKES
# ==============================================================================
echo -e "\n${GREEN}${BOLD}▬▬▬▬▬▬ TASK 2: DEFINE SPOKES ▬▬▬▬▬▬${RESET}"
echo -e "${YELLOW}[*] Creating Spoke: office-1-spoke in $R1...${RESET}"
gcloud network-connectivity spokes linked-vpn-tunnels create office-1-spoke \
--hub=ncc-hub \
--region=$R1 \
--vpn-tunnels=$T1_NAMES \
--site-to-site-data-transfer \
--quiet
echo -e "${YELLOW}[*] Creating Spoke: office-2-spoke in $R2...${RESET}"
gcloud network-connectivity spokes linked-vpn-tunnels create office-2-spoke \
--hub=ncc-hub \
--region=$R2 \
--vpn-tunnels=$T2_NAMES \
--site-to-site-data-transfer \
--quiet
echo -e "\n${MAGENTA}${BOLD}╔════════════════════════════════════════════════════════════╗${RESET}"
echo -e "${MAGENTA}${BOLD}║ 🎉 AUTOMATION COMPLETED SUCCESSFULLY 🎉 ║${RESET}"
echo -e "${MAGENTA}${BOLD}╚════════════════════════════════════════════════════════════╝${RESET}"
echo -e "${CYAN}${BOLD}You may now return to the Qwiklabs manual and click 'Check my progress' to claim your 100/100!${RESET}"