0
0
GCPcloud~30 mins

Resource naming and labels in GCP - Mini Project: Build & Apply

Choose your learning style9 modes available
Resource naming and labels
📖 Scenario: You are managing cloud resources for a small company. To keep things organized, you need to name your resources clearly and add labels that describe their purpose and environment.
🎯 Goal: Create a Google Cloud Storage bucket with a proper name and add labels to it for environment and team ownership.
📋 What You'll Learn
Create a bucket name variable with the exact name 'company-data-prod'.
Create a labels dictionary with keys 'environment' and 'team' and values 'production' and 'analytics' respectively.
Use the Google Cloud Storage client to create a bucket with the given name and labels.
Ensure the bucket creation code includes the labels in the bucket metadata.
💡 Why This Matters
🌍 Real World
In real cloud projects, naming resources clearly and adding labels helps teams find, manage, and automate resources easily.
💼 Career
Cloud engineers and administrators use naming conventions and labels daily to organize resources and control costs.
Progress0 / 4 steps
1
Create the bucket name variable
Create a variable called bucket_name and set it to the string 'company-data-prod'.
GCP
Need a hint?

Use simple assignment to create the variable bucket_name.

2
Create the labels dictionary
Create a dictionary called labels with the exact keys and values: 'environment': 'production' and 'team': 'analytics'.
GCP
Need a hint?

Use curly braces to create the dictionary with the exact keys and values.

3
Import the storage client and initialize it
Import storage from google.cloud and create a client instance called storage_client.
GCP
Need a hint?

Use from google.cloud import storage and then create storage.Client().

4
Create the bucket with labels
Use storage_client to create a bucket with the name bucket_name. Set the bucket's labels property to the labels dictionary before creating it with storage_client.create_bucket().
GCP
Need a hint?

Create a bucket object, assign labels, then call create_bucket with it.