Knowledge Catalog: Qwik Start - Command Line

Solution for Knowledge Catalog: Qwik Start - Command Line. 1 lab: GSP1144. Fast copy-paste commands for Google Cloud.

GSP1144 — Knowledge Catalog: Qwik Start - Command Line

Estimated time: 15 minutes

# 🏗️ Build a Data Mesh with Knowledge Catalog > ⚠️ **Disclaimer:** This is an independent, community-made walkthrough created to help you understand Google Cloud services and modern data governance concepts. It is intended solely for educational purposes, hands-on learning, and Google Cloud certification preparation. Attempt the lab yourself before using this guide. This walkthrough is **not affiliated with or endorsed by Google, Google Cloud, Google Cloud Skills Boost, or Qwiklabs**. Always f

#!/bin/bash
# ==============================================================================
# ORBIT OF OPS - PART 1: DATA MESH CREATION (GSP1144)
# ==============================================================================
GREEN='\e[1;32m'
CYAN='\e[1;36m'
YELLOW='\e[1;33m'
BLUE='\e[1;34m'
MAGENTA='\e[1;35m'
WHITE='\e[1;37m'
RED='\e[1;31m'
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}║   🚀 PART 1: BUILD KNOWLEDGE CATALOG DATA MESH             ║${RESET}"
echo -e "${BLUE}${BOLD}║   🌐 BROUGHT TO YOU BY ORBIT OF OPS                        ║${RESET}"
echo -e "${BLUE}${BOLD}╚════════════════════════════════════════════════════════════╝${RESET}\n"

echo -e "${YELLOW}${BOLD}[Orbit of Ops] Auto-fetching Project and Region...${RESET}"
export PROJECT_ID=$(gcloud config get-value project 2>/dev/null)
if [[ -z "$PROJECT_ID" ]]; then
    export PROJECT_ID=$DEVSHELL_PROJECT_ID
fi

export ZONE=$(gcloud compute project-info describe \
    --format="value(commonInstanceMetadata.items[google-compute-default-zone])" 2>/dev/null | tail -n 1)

if [[ -z "$ZONE" ]]; then
    echo -e "${BOLD}${RED}⚠️ Could not auto-detect the default zone via gcloud metadata.${RESET}"
    read -p "Please enter the lab Zone (e.g., us-central1-a): " ZONE
    export ZONE
fi

export REGION=${ZONE%-*}
gcloud config set compute/region $REGION 2>/dev/null

echo -e "✅ Project ID: ${GREEN}$PROJECT_ID${RESET}"
echo -e "✅ Region:     ${GREEN}$REGION${RESET}\n"

echo -e "${BLUE}${BOLD}[Orbit of Ops] Enabling Dataplex API...${RESET}"
gcloud services enable dataplex.googleapis.com

echo -e "\n${BLUE}${BOLD}[Orbit of Ops] Task 1: Creating 'ecommerce' Lake (Handling lazy provisioning)...${RESET}"
CREATE_LAKE_CMD="gcloud dataplex lakes create ecommerce --location=$REGION --display-name=\"Ecommerce\" --description=\"Ecommerce Domain\""
eval $CREATE_LAKE_CMD || { echo -e "${YELLOW}API sync delay detected. Waiting 45s and retrying...${RESET}"; sleep 45; eval $CREATE_LAKE_CMD; }

echo -e "\n${BLUE}${BOLD}[Orbit of Ops] Task 2: Adding 'orders-curated-zone' to Lake...${RESET}"
gcloud dataplex zones create orders-curated-zone \
    --location=$REGION \
    --lake=ecommerce \
    --display-name="Orders Curated Zone" \
    --resource-location-type=SINGLE_REGION \
    --type=CURATED \
    --discovery-enabled \
    --discovery-schedule="0 * * * *"

echo -e "\n${BLUE}${BOLD}[Orbit of Ops] Task 3A: Creating BigQuery Dataset...${RESET}"
bq mk --location=$REGION --dataset orders

echo -e "\n${BLUE}${BOLD}[Orbit of Ops] Task 3B: Attaching Dataset to Zone as an Asset...${RESET}"
gcloud dataplex assets create orders-curated-dataset \
    --location=$REGION \
    --lake=ecommerce \
    --zone=orders-curated-zone \
    --display-name="Orders Curated Dataset" \
    --resource-type=BIGQUERY_DATASET \
    --resource-name=projects/$PROJECT_ID/datasets/orders \
    --discovery-enabled

echo -e "\n${MAGENTA}${BOLD}╔════════════════════════════════════════════════════════════╗${RESET}"
echo -e "${MAGENTA}${BOLD}║  🎉 PART 1 COMPLETE! VERIFY PROGRESS IN LAB MANUAL NOW! 🎉 ║${RESET}"
echo -e "${MAGENTA}${BOLD}╚════════════════════════════════════════════════════════════╝${RESET}"
echo -e "${WHITE}${BOLD}⚠️ DO NOT RUN PART 2 UNTIL YOU HAVE THE POINTS FOR TASKS 1, 2, AND 3!${RESET}"
#!/bin/bash
# ==============================================================================
# ORBIT OF OPS - PART 2: RESOURCE TEARDOWN (GSP1144)
# ==============================================================================
GREEN='\e[1;32m'
CYAN='\e[1;36m'
YELLOW='\e[1;33m'
BLUE='\e[1;34m'
MAGENTA='\e[1;35m'
RESET='\e[0m'
BOLD='\e[1m'

echo -e "\n${CYAN}${BOLD}╔════════════════════════════════════════════════════════════╗${RESET}"
echo -e "${CYAN}${BOLD}║   🗑️  PART 2: DATA MESH TEARDOWN (TASK 4)                  ║${RESET}"
echo -e "${CYAN}${BOLD}║   🌐 BROUGHT TO YOU BY ORBIT OF OPS                        ║${RESET}"
echo -e "${CYAN}${BOLD}╚════════════════════════════════════════════════════════════╝${RESET}\n"

echo -e "${BLUE}${BOLD}[Orbit of Ops] Detaching Asset...${RESET}"
gcloud dataplex assets delete orders-curated-dataset \
    --location=$REGION \
    --zone=orders-curated-zone \
    --lake=ecommerce \
    --quiet

echo -e "\n${BLUE}${BOLD}[Orbit of Ops] Deleting Zone...${RESET}"
gcloud dataplex zones delete orders-curated-zone \
    --location=$REGION \
    --lake=ecommerce \
    --quiet

echo -e "\n${BLUE}${BOLD}[Orbit of Ops] Deleting Lake...${RESET}"
gcloud dataplex lakes delete ecommerce \
    --location=$REGION \
    --quiet

echo -e "\n${MAGENTA}${BOLD}╔════════════════════════════════════════════════════════════╗${RESET}"
echo -e "${MAGENTA}${BOLD}║   🎉 ALL TASKS COMPLETE! VERIFY FINAL PROGRESS! 🎉         ║${RESET}"
echo -e "${MAGENTA}${BOLD}╚════════════════════════════════════════════════════════════╝${RESET}"