0
0
GCPcloud~10 mins

Why IaC matters in GCP - Visual Breakdown

Choose your learning style9 modes available
Process Flow - Why IaC matters
Write Infrastructure Code
Run Code to Create Resources
Cloud Provider Builds Resources
Resources Ready to Use
Manage & Update by Changing Code
Repeat: Code Controls Infrastructure
Infrastructure as Code means writing code to create and manage cloud resources automatically, making setup and updates easy and consistent.
Execution Sample
GCP
resource "google_compute_instance" "vm1" {
  name         = "vm-instance"
  machine_type = "e2-medium"
  zone         = "us-central1-a"
  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-10"
    }
  }
  network_interface {
    network = "default"
    access_config {}
  }
}
This code defines a virtual machine instance in GCP that will be created automatically when applied.
Process Table
StepActionCode EvaluationResult
1Parse IaC codeRead resource blockRecognize VM instance definition
2Send request to GCPCreate VM with name 'vm-instance'VM creation started
3GCP provisions VMAllocate machine type e2-medium in zone us-central1-aVM is created and running
4Confirm resource stateCheck VM statusVM is ready to use
5Update codeChange machine_type to e2-standard-2Prepare update plan
6Apply updateSend update request to GCPVM machine type updated
7Verify updateCheck VM machine typeVM runs with new machine type
8EndNo more changesInfrastructure matches code
💡 All infrastructure resources are created and managed by code, ensuring consistency and easy updates.
Status Tracker
VariableStartAfter Step 2After Step 3After Step 6Final
VM Instanceundefinedcreation requestedrunning with e2-mediumupdated to e2-standard-2running with e2-standard-2
Key Moments - 2 Insights
Why do we write code instead of manually creating resources in the cloud?
Writing code lets us create and update resources automatically and consistently, as shown in execution_table steps 1 to 4, avoiding manual errors.
How does changing the code update the cloud resources?
Changing the code triggers an update plan and applies changes to the cloud, as seen in steps 5 to 7, keeping infrastructure in sync with code.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3, what is the state of the VM instance?
AVM is running with machine type e2-medium
BVM is stopped
CVM creation requested but not started
DVM machine type is e2-standard-2
💡 Hint
Check the 'Result' column at step 3 in execution_table.
At which step does the VM machine type get updated?
AStep 4
BStep 6
CStep 5
DStep 7
💡 Hint
Look for 'Apply update' action in execution_table.
If we skip step 5 (update code), what happens to the VM machine type?
AVM is deleted
BIt changes to e2-standard-2 anyway
CIt stays as e2-medium
DVM machine type becomes undefined
💡 Hint
Refer to variable_tracker and see how machine type changes only after step 5 and 6.
Concept Snapshot
IaC means writing code to create and manage cloud resources.
Run the code to build resources automatically.
Change code to update resources safely.
Keeps infrastructure consistent and repeatable.
Avoids manual setup errors and saves time.
Full Transcript
Infrastructure as Code (IaC) lets you write code to create and manage cloud resources instead of doing it manually. When you run the code, the cloud provider builds the resources for you. If you want to change something, you update the code and run it again. The cloud updates the resources to match your code. This way, your infrastructure is always consistent, easy to manage, and less error-prone.