Instance states (running, stopped, terminated)
📖 Scenario: You are managing virtual machines (instances) in Google Cloud Platform (GCP). Each instance can be in one of three states: running, stopped, or terminated. You want to organize and track these instances by their states.
🎯 Goal: Create a data structure to hold instance names and their states, add a filter to select only running instances, then list those running instances, and finally configure a simple output format to display them.
📋 What You'll Learn
Create a dictionary called
instances with exact instance names and statesAdd a variable called
desired_state set to the string 'running'Use a list comprehension called
running_instances to select instance names with state matching desired_stateCreate a final dictionary called
output with key 'running_instances' and value running_instances💡 Why This Matters
🌍 Real World
Cloud administrators often need to track and manage virtual machine states to optimize costs and performance.
💼 Career
Understanding instance states and filtering them programmatically is essential for cloud operations and automation roles.
Progress0 / 4 steps