0
0
GCPcloud~30 mins

Output formatting in GCP - Mini Project: Build & Apply

Choose your learning style9 modes available
Output formatting
📖 Scenario: You are working with Google Cloud Platform (GCP) and want to create a simple Cloud Storage bucket with a specific output format for its metadata. This will help you see the bucket details clearly when you check its properties.
🎯 Goal: Create a Cloud Storage bucket configuration and format its output metadata in a clear, readable way.
📋 What You'll Learn
Create a variable called bucket_config with the bucket name and location
Add a variable called output_format to specify JSON formatting
Use a function called format_output to apply the output format to the bucket metadata
Complete the configuration by setting the formatted_output variable with the formatted bucket metadata
💡 Why This Matters
🌍 Real World
Cloud engineers often need to configure resources and format their metadata outputs clearly for monitoring and documentation.
💼 Career
Understanding how to structure cloud resource configurations and format their outputs is essential for managing cloud infrastructure efficiently.
Progress0 / 4 steps
1
Create the initial bucket configuration
Create a dictionary called bucket_config with these exact entries: "name": "my-sample-bucket" and "location": "us-central1".
GCP
Need a hint?

Use curly braces to create a dictionary with the keys "name" and "location".

2
Add the output format configuration
Add a variable called output_format and set it to the string "json_pretty" to specify the output format.
GCP
Need a hint?

Assign the string "json_pretty" to the variable output_format.

3
Create the output formatting function
Define a function called format_output that takes two parameters: config and format_type. Inside the function, return a string that says "Formatted output for bucket: " plus the bucket name from config.
GCP
Need a hint?

Use def to define the function and access the bucket name with config["name"].

4
Set the formatted output variable
Create a variable called formatted_output and set it by calling the format_output function with bucket_config and output_format as arguments.
GCP
Need a hint?

Call format_output with the two variables and assign the result to formatted_output.