gcloud compute instances set-machine-type INSTANCE_NAME --machine-type NEW_TYPE -> Option D
Quick Check:
Change machine type command = set-machine-type [OK]
Hint: Use 'set-machine-type' to change VM size with gcloud [OK]
Common Mistakes:
Using incorrect verbs like 'change-type' or 'modify'
Mixing VM commands with wrong flags
Assuming 'vm update' is valid gcloud syntax
3. Consider this Python snippet using Google Cloud SDK to list machine types in a zone:
from google.cloud import compute_v1
client = compute_v1.MachineTypesClient()
machine_types = client.list(project='my-project', zone='us-central1-a')
for mt in machine_types:
if mt.name == 'n1-standard-1':
print(mt.memory_mb)
What will this code output?
medium
A. The memory size in MB of the 'n1-standard-1' machine type
B. The CPU count of the 'n1-standard-1' machine type
C. An error because 'memory_mb' is not a valid attribute
D. No output because the loop never finds 'n1-standard-1'
Solution
Step 1: Understand the code logic
The code lists machine types in the specified zone and checks for the one named 'n1-standard-1'.
Step 2: Identify the output for matching machine type
When it finds 'n1-standard-1', it prints the memory size in MB, which is a valid attribute.
Final Answer:
The memory size in MB of the 'n1-standard-1' machine type -> Option A
Quick Check:
Print memory_mb for 'n1-standard-1' = memory size [OK]
Hint: Look for matching name, then print memory_mb attribute [OK]
Common Mistakes:
Confusing memory_mb with CPU count
Assuming attribute 'memory_mb' does not exist
Thinking loop won't find the machine type
4. A user tries to resize a Compute Engine VM but gets an error. The command used is:
A. The VM must be stopped before changing its machine type
B. The machine type 'n1-standard-4' does not exist
C. The command syntax is incorrect
D. The user does not have permission to list machine types
Solution
Step 1: Recall Compute Engine resizing rules
To change a VM's machine type, the VM must be stopped first.
Step 2: Analyze the error cause
If the VM is running, the command will fail with an error about the VM state.
Final Answer:
The VM must be stopped before changing its machine type -> Option A
Quick Check:
Stop VM before resize = required [OK]
Hint: Stop VM before resizing machine type [OK]
Common Mistakes:
Assuming machine type name is invalid
Thinking command syntax is wrong
Ignoring VM running state requirement
5. You want to optimize costs by resizing your Compute Engine VM based on workload changes. Which approach best uses Compute Engine's flexibility features?
hard
A. Manually delete and recreate VMs with different sizes every time workload changes
B. Use custom machine types and resize VM during low and high workload periods
C. Use only predefined machine types and never change VM size after creation
D. Create multiple fixed-size VMs and keep them all running constantly
Solution
Step 1: Understand Compute Engine flexibility
Compute Engine allows custom machine types and resizing VMs to match workload needs.
Step 2: Identify cost optimization strategy
Resizing VMs during workload changes saves cost and improves efficiency compared to fixed or manual recreation.
Final Answer:
Use custom machine types and resize VM during low and high workload periods -> Option B
Quick Check:
Resize VM with custom types for cost saving [OK]
Hint: Resize VMs with custom types to match workload [OK]