0
0
GCPcloud~30 mins

Scripting with gcloud in GCP - Mini Project: Build & Apply

Choose your learning style9 modes available
Scripting with gcloud
📖 Scenario: You are working as a cloud engineer managing Google Cloud Platform resources. You want to automate the creation and management of a Compute Engine virtual machine using simple scripts with the gcloud command-line tool.
🎯 Goal: Build a step-by-step script using gcloud commands to create a VM instance, configure its zone, and add a startup script that runs when the VM boots.
📋 What You'll Learn
Use gcloud config set compute/zone to set the default zone
Create a VM instance named my-vm-instance with the e2-micro machine type
Add a startup script that echoes 'Hello, Cloud!' to a file on the VM
Verify the VM instance creation command includes the startup script metadata
💡 Why This Matters
🌍 Real World
Automating cloud resource management saves time and reduces errors in real projects.
💼 Career
Cloud engineers and DevOps professionals use gcloud scripting daily to manage Google Cloud resources efficiently.
Progress0 / 4 steps
1
Set the default compute zone
Write the gcloud command to set the default compute zone to us-central1-a using gcloud config set compute/zone.
GCP
Need a hint?

Use the command gcloud config set compute/zone us-central1-a to set the zone.

2
Create a VM instance named my-vm-instance
Write the gcloud command to create a VM instance named my-vm-instance with machine type e2-micro.
GCP
Need a hint?

Use gcloud compute instances create my-vm-instance --machine-type=e2-micro to create the VM.

3
Add a startup script to the VM instance
Modify the VM creation command to include a startup script that writes 'Hello, Cloud!' to /var/log/startup-script.log using the metadata flag --metadata startup-script.
GCP
Need a hint?

Add --metadata startup-script="echo 'Hello, Cloud!' > /var/log/startup-script.log" to the create command.

4
Verify the VM instance creation command
Ensure the full command includes setting the zone, creating the VM named my-vm-instance with machine type e2-micro, and the startup script metadata as shown.
GCP
Need a hint?

Check that all parts of the command are included exactly as shown.