Organize and Govern Data with Knowledge Catalog
Solution for Organize and Govern Data with Knowledge Catalog. 1 lab: ARC117. Fast copy-paste commands for Google Cloud.
ARC117 — Organize and Govern Data with Knowledge Catalog: Challenge Lab
Estimated time: 25 minutes
# ==============================================================================
# ORBIT OF OPS: ARC117 - COMMAND 1 (TRUE AUTO-FETCH)
# ==============================================================================
GREEN=$(tput setaf 2)
CYAN=$(tput setaf 6)
YELLOW=$(tput setaf 3)
MAGENTA=$(tput setaf 5)
WHITE=$(tput setaf 7)
RESET=$(tput sgr0)
BOLD=$(tput bold)
BG_RED=$(tput setab 1)
echo "${CYAN}${BOLD}"
echo " ____ _ _ _ __ ___ "
echo " / __ \ | | (_) | / _| / _ \ "
echo " | | | |_ __| |__ _| |_ ___ | |_ | | | |_ __ ___ "
echo " | | | | '__| '_ \| | __| / _ \ | _|| | | | '_ \/ __| "
echo " | |__| | | | |_) | | |_ | (_) || | | |_| | |_) \__ \ "
echo " \____/|_| |_.__/|_|\__| \___/ |_| \___/| .__/|___/ "
echo " | | "
echo " |_| "
echo "${RESET}"
echo "${MAGENTA}${BOLD}>>> ORBIT OF OPS: ARC117 INITIALIZED <<<${RESET}"
export PROJECT_ID=$(gcloud config get-value project)
echo "${GREEN}${BOLD}[*] Scanning Google Cloud metadata for Region data...${RESET}"
# Using the robust metadata fetcher from our previous deployments
ZONE_FETCH=$(gcloud compute project-info describe --format="value(commonInstanceMetadata.items[google-compute-default-zone])" 2>/dev/null)
if [ -n "$ZONE_FETCH" ]; then
# Strip the zone letter to get the region (e.g., us-east4-b becomes us-east4)
LOCATION=${ZONE_FETCH%-*}
else
# Fallback to local config
LOCATION=$(gcloud config get-value compute/region 2>/dev/null)
fi
# Final safety net prompt (just in case Qwiklabs completely hides the metadata)
if [ -z "$LOCATION" ]; then
echo -e "\n${BG_RED}${WHITE}${BOLD} [!] AUTO-FETCH FAILED: Qwiklabs hid the metadata. ${RESET}"
read -p "${YELLOW}${BOLD}Please manually type your lab REGION (e.g., us-east4) and press ENTER: ${RESET}" LOCATION </dev/tty
fi
export LOCATION
echo "${YELLOW}Project ID: ${PROJECT_ID}${RESET}"
echo "${YELLOW}Region identified: ${LOCATION}${RESET}"
echo "${GREEN}${BOLD}[*] Enabling Dataplex and Data Catalog APIs...${RESET}"
gcloud services enable datacatalog.googleapis.com dataplex.googleapis.com
sleep 3
echo "${GREEN}${BOLD}[*] Task 1: Creating Knowledge Catalog Lake and Raw Zone...${RESET}"
gcloud dataplex lakes create customer-engagements \
--location=$LOCATION \
--display-name="Customer Engagements" \
--quiet
gcloud dataplex zones create raw-event-data \
--location=$LOCATION \
--lake=customer-engagements \
--display-name="Raw Event Data" \
--type=RAW \
--resource-location-type=SINGLE_REGION \
--discovery-enabled \
--quiet
echo "${GREEN}${BOLD}[*] Task 2: Creating Cloud Storage Bucket...${RESET}"
gcloud storage buckets create gs://$PROJECT_ID --location=$LOCATION --quiet
echo "${GREEN}${BOLD}[*] Attaching Bucket as a Regional Asset to the Raw Zone...${RESET}"
gcloud dataplex assets create raw-event-files \
--location=$LOCATION \
--lake=customer-engagements \
--zone=raw-event-data \
--display-name="Raw Event Files" \
--resource-type=STORAGE_BUCKET \
--resource-name=projects/$PROJECT_ID/buckets/$PROJECT_ID \
--quiet
echo "${CYAN}${BOLD}>>> TASKS 1 & 2 COMPLETE! Proceed to Command 2. <<<${RESET}"# ==============================================================================
# ORBIT OF OPS: ARC117 - COMMAND 2 (TASK 3 UI GUIDE)
# ==============================================================================
GREEN=$(tput setaf 2)
CYAN=$(tput setaf 6)
YELLOW=$(tput setaf 3)
MAGENTA=$(tput setaf 5)
WHITE=$(tput setaf 7)
RESET=$(tput sgr0)
BOLD=$(tput bold)
BG_RED=$(tput setab 1)
LOCATION=$(gcloud config get-value compute/region 2>/dev/null)
if [ -z "$LOCATION" ]; then
ZONE=$(gcloud config get-value compute/zone 2>/dev/null)
LOCATION=${ZONE%-*}
fi
echo -e "\n${BG_RED}${WHITE}${BOLD}>>> ACTION REQUIRED FOR TASK 3 <<<${RESET}"
echo "${YELLOW}${BOLD}Task 3 requires manual UI setup to ensure credit safety for Dataplex Aspects.${RESET}"
echo "${CYAN}1.${RESET} ${WHITE}In the Google Cloud Console, search for ${BOLD}Dataplex${RESET}${WHITE} and open it.${RESET}"
echo "${CYAN}2.${RESET} ${WHITE}On the left menu under ${BOLD}Catalog${RESET}${WHITE}, click ${BOLD}Aspect Types${RESET}${WHITE} (or Templates).${RESET}"
echo "${CYAN}3.${RESET} ${WHITE}Click ${BOLD}+ CREATE ASPECT TYPE${RESET}${WHITE}.${RESET}"
echo "${CYAN}4.${RESET} ${WHITE}Name it: ${BOLD}Protected Raw Data Aspect${RESET}${WHITE} (Location: ${BOLD}${LOCATION}${RESET}${WHITE}).${RESET}"
echo "${CYAN}5.${RESET} ${WHITE}Add a field named: ${BOLD}Protected Raw Data Flag${RESET}${WHITE}.${RESET}"
echo "${CYAN}6.${RESET} ${WHITE}Set the field type to ${BOLD}Enumerated${RESET}${WHITE} (or Enum) and add two values: ${BOLD}Y${RESET}${WHITE} and ${BOLD}N${RESET}${WHITE}.${RESET}"
echo "${CYAN}7.${RESET} ${WHITE}Save/Create the Aspect Type.${RESET}"
echo "${CYAN}8.${RESET} ${WHITE}Go back to ${BOLD}Manage > Lakes${RESET}${WHITE}, click your ${BOLD}Customer Engagements${RESET}${WHITE} lake, and open the ${BOLD}Raw Event Data${RESET}${WHITE} zone.${RESET}"
echo "${CYAN}9.${RESET} ${WHITE}Click ${BOLD}ADD ASPECT${RESET}${WHITE} and attach the ${BOLD}Protected Raw Data Aspect${RESET}${WHITE} you just created.${RESET}"
echo ""
echo "${CYAN}${BOLD}"
echo " ____ _ _ _ __ ___ "
echo " / __ \ | | (_) | / _| / _ \ "
echo " | | | |_ __| |__ _| |_ ___ | |_ | | | |_ __ ___ "
echo " | | | | '__| '_ \| | __| / _ \ | _|| | | | '_ \/ __| "
echo " | |__| | | | |_) | | |_ | (_) || | | |_| | |_) \__ \ "
echo " \____/|_| |_.__/|_|\__| \___/ |_| \___/| .__/|___/ "
echo " | | "
echo " |_| "
echo "${RESET}"
echo "${MAGENTA}${BOLD}>>> ALL TASKS COMPLETE! Click 'Check my progress' on the lab page! <<<${RESET}"
echo ""