Dataplex: Qwik Start - Command Line - GSP1144


Overview
Dataplex is an intelligent data fabric that enables organizations to centrally discover, manage, monitor, and govern their data across data lakes, data warehouses, and data marts to power analytics at scale. Specifically, you can use Dataplex to build a data mesh architecture, which is an organizational and technical approach that decentralizes data ownership among domain data owners.
Dataplex manages data in a way that doesn’t require data movement or duplication. As you add new data assets, Dataplex harvests the metadata for both structured and unstructured data, and automatically registers all metadata in a secure, unified metastore. Data and metadata can then be assessed via Google Cloud services such as Data Catalog and BigQuery.
In this lab, you learn how to start building your own data mesh by creating and removing lakes, zones, and assets in Dataplex using the command line.
What you'll do
Enable the Dataplex API
Create a lake
Add a zone to your lake
Attach and detach assets
Delete zones and lakes
Setup and requirements
Before you click the Start Lab button
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
- Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito (recommended) or private browser window to run this lab. This prevents conflicts between your personal account and the student account, which may cause extra charges incurred to your personal account.
- Time to complete the lab—remember, once you start, you cannot pause a lab.
Note: Use only the student account for this lab. If you use a different Google Cloud account, you may incur charges to that account.
How to start your lab and sign in to the Google Cloud console
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
The Open Google Cloud console button
Time remaining
The temporary credentials that you must use for this lab
Other information, if needed, to step through this lab
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
Note: If you see the Choose an account dialog, click Use Another Account.
If necessary, copy the Username below and paste it into the Sign in dialog.
student-04-4ee3cfba204c@qwiklabs.net
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
voSvwGtSalBA
You can also find the Password in the Lab Details pane.
Click Next.
Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials.
Note: Using your own Google Cloud account for this lab may incur extra charges.
Click through the subsequent pages:
Accept the terms and conditions.
Do not add recovery options or two-factor authentication (because this is a temporary account).
Do not sign up for free trials.
After a few moments, the Google Cloud console opens in this tab.
Note: To access Google Cloud products and services, click the Navigation menu or type the service or product name in the Search field.
Activate Cloud Shell
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
Continue through the Cloud Shell information window.
Authorize Cloud Shell to use your credentials to make Google Cloud API calls.
When you are connected, you are already authenticated, and the project is set to your Project_ID, qwiklabs-gcp-02-e9ed97dd299e
. The output contains a line that declares the Project_ID for this session:
Your Cloud Platform project in this session is set to qwiklabs-gcp-02-e9ed97dd299e
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
- (Optional) You can list the active account name with this command:
gcloud auth list
- Click Authorize.
Output:
ACTIVE: *
ACCOUNT: student-04-4ee3cfba204c@qwiklabs.net
To set the active account, run:
$ gcloud config set account `ACCOUNT`
- (Optional) You can list the project ID with this command:
gcloud config list project
Output:
[core]
project = qwiklabs-gcp-02-e9ed97dd299e
Note: For full documentation of gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
Enable the Dataplex API and set variables
- In Cloud Shell, run the following command to enable the Dataplex API.
gcloud services enable \
dataplex.googleapis.com
- Run the following command to create a variable for project ID:
export PROJECT_ID=$(gcloud config get-value project)
- Run the following command to create a variable for region:
export REGION=us-east1
gcloud config set compute/region $REGION
Task 1. Create a lake
In Dataplex, a lake is the highest organizational domain that represents a specific data area or business unit. For example, you can create a lake for each department or data domain in your organization, so that you can organize and provide data for specific user groups.
In this task, you use the command line to create a lake to start building a data mesh.
- In Cloud Shell, run the following command to create a new lake called Ecommerce:
gcloud dataplex lakes create ecommerce \
--location=$REGION \
--display-name="Ecommerce" \
--description="Ecommerce Domain"
It can take up to 3 minutes for the lake to be created.
If you receive an error of Status code: 403. Permission 'dataplex.lakes.create' denied
, wait a few minutes and try again. The permissions may need more time to be granted after enabling the Dataplex API in the previous Setup section.
The final output should look similar to the following:
Created [ecommerce] Lake created in [projects/$PROJECT_ID/locations/$REGION].
Step successfully completed.
Create a Dataplex lake
Check my progress
Step successfully completed.
Task 2. Add a zone to your lake
After you create a lake, you can add zones to the lake. Zones are subdomains within a lake that you can use to categorize data further. For example, you can categorize data by stage, usage, or restrictions.
There are two types of zones:
Raw zones contain data in raw formats (such as files in Cloud Storage buckets) and are not subject to strict type-checking.
Curated zones contain data that is cleaned, formatted, and ready for analytics such as BigQuery datasets.
In this task, you use the command line to create a curated zone for working with BigQuery datasets.
- In Cloud Shell, run the following command to create a new curated zone called Orders Curated Zone with metadata discovery enabled:
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 * * * *"
It can take up to 2 minutes for the zone to be created.
The final output should look similar to the following:
Created [orders-curated-zone] Zone created in [projects/$PROJECT_ID/locations/$REGION/lakes/ecommerce].
Step successfully completed.
Add a zone to your lake
Check my progress
Step successfully completed.
Task 3. Attach an asset to a zone
Data stored in Cloud Storage buckets or BigQuery datasets can be attached as assets to zones within a Dataplex lake.
In this task, you use the command line to create a BigQuery dataset and then attach the dataset to the previously created zone.
Create a BigQuery dataset
- In Cloud Shell, run the following command to create a new BigQuery dataset called orders:
bq mk --location=$REGION --dataset orders
While this dataset does not contain any tables or data, you can attach it to the zone now, and newly created tables and loaded data will automatically be integrated into the zone.
The final output should look similar to the following:
Dataset '$PROJECT_ID:orders' successfully created.
Attach the BigQuery dataset to the zone
- In Cloud Shell, run the following command to attach the BigQuery dataset to the zone as an asset called Orders Curated Data with metadata discovery enabled:
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
It can take up to 2 minutes for the asset to be created.
The final output should look similar to the following:
Created [orders-curated-dataset] Asset created in [projects/$PROJECT_ID/locations/$REGION/lakes/ecommerce/zones/orders-curated-zone].
Attach an asset to a zone
Check my progress
Task 4. Delete assets, zones, and lakes
To delete a lake, you must first detach assets and then delete the zones.
In this task, you use the command line to detach the asset from the zone, then delete the zone, and last, delete the lake.
Detach an asset
- In Cloud Shell, run the following command to detach the BigQuery dataset from the zone:
gcloud dataplex assets delete orders-curated-dataset --location=$REGION --zone=orders-curated-zone --lake=ecommerce
If prompted to confirm, enter Y
.
This action does delete the underlying data in the BigQuery dataset. It simply removes the BigQuery dataset from being accessible or discoverable using the lake in Dataplex.
The final output should look similar to the following:
Deleted asset [orders-curated-dataset].
Delete a zone
- In Cloud Shell, run the following command to delete the zone:
gcloud dataplex zones delete orders-curated-zone --location=$REGION --lake=ecommerce
If prompted to confirm, enter Y
.
The final output should look similar to the following:
Deleted zone [orders-curated-zone].
Delete the lake
- In Cloud Shell, run the following command to delete the lake:
gcloud dataplex lakes delete ecommerce --location=$REGION
If prompted to confirm, enter Y
.
The final output should look similar to the following:
Deleted lake [ecommerce].
Delete assets, zone and dataplex lake
Check my progress
Solution of Lab
curl -LO raw.githubusercontent.com/ArcadeCrew/Google-Cloud-Labs/refs/heads/main/Dataplex%20Qwik%20Start%20-%20Command%20Line/arcadecrew.sh
sudo chmod +x arcadecrew.sh
./arcadecrew.sh
Subscribe to my newsletter
Read articles from David Nguyen directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

David Nguyen
David Nguyen
A passionate full-stack developer from @ePlus.DEV