0
0
GCPcloud~30 mins

Variables and outputs in GCP - Mini Project: Build & Apply

Choose your learning style9 modes available
Using Variables and Outputs in GCP Deployment Manager
📖 Scenario: You are setting up a simple Google Cloud Platform (GCP) deployment using Deployment Manager. You want to create a virtual machine instance with a specific name and zone, and then output the instance's selfLink URL after deployment.
🎯 Goal: Build a Deployment Manager configuration that uses variables to define the VM instance name and zone, and outputs the instance's selfLink URL.
📋 What You'll Learn
Create a variable called instanceName with the value my-vm-instance.
Create a variable called zone with the value us-central1-a.
Define a resource of type compute.v1.instance using the variables for name and zone.
Add an output called instanceSelfLink that outputs the selfLink of the created instance.
💡 Why This Matters
🌍 Real World
Cloud engineers often use Deployment Manager to automate creating and managing cloud resources with reusable templates.
💼 Career
Knowing how to use variables and outputs in cloud templates is essential for infrastructure as code roles and cloud automation tasks.
Progress0 / 4 steps
1
Create variables for instance name and zone
Create a variable called instanceName and set it to my-vm-instance. Also create a variable called zone and set it to us-central1-a.
GCP
Need a hint?

Use YAML syntax to define variables with exact names and values.

2
Add a resource using the variables
Add a resource named vm-instance of type compute.v1.instance. Use the variables instanceName for the resource name and zone for the resource zone property.
GCP
Need a hint?

Use $(variableName) syntax to reference variables inside properties.

3
Add an output for the instance selfLink
Add an output called instanceSelfLink that outputs the selfLink of the resource named vm-instance.
GCP
Need a hint?

Outputs use $(ref.resourceName.property) syntax to get resource properties.

4
Complete the deployment configuration
Ensure the deployment configuration includes the variables instanceName and zone, the resource vm-instance using those variables, and the output instanceSelfLink with the correct reference.
GCP
Need a hint?

Check that all parts are present and correctly linked.