0
0
Terraformcloud~10 mins

Why resources are Terraform's core - Visual Breakdown

Choose your learning style9 modes available
Process Flow - Why resources are Terraform's core
Define Resource Block
Terraform Reads Config
Create/Update Resource
Track Resource State
Manage Infrastructure
Apply Changes or Destroy
Terraform uses resource blocks to know what cloud parts to create or change. It reads these, makes the resources, tracks them, and manages updates.
Execution Sample
Terraform
resource "aws_instance" "example" {
  ami           = "ami-123456"
  instance_type = "t2.micro"
}
This code tells Terraform to create a small AWS server using a specific image.
Process Table
StepActionResource State BeforeTerraform OperationResource State After
1Read resource blockNo aws_instance.exampleParse configPrepare to create aws_instance.example
2Plan executionNo aws_instance.exampleCompare desired vs currentPlan to create aws_instance.example
3Apply changesNo aws_instance.exampleSend create request to AWSaws_instance.example created
4Update state fileaws_instance.example createdRecord resource infoState file updated with aws_instance.example
5Next applyaws_instance.example existsCheck for changesNo changes, resource unchanged
6Destroy resourceaws_instance.example existsSend delete request to AWSaws_instance.example removed
7Update state fileaws_instance.example removedRemove resource from stateState file updated, resource removed
💡 Terraform stops when resource state matches desired config or resource is destroyed.
Status Tracker
VariableStartAfter Step 3After Step 5After Step 7
aws_instance.exampleundefinedcreatedunchangeddeleted
Key Moments - 3 Insights
Why does Terraform keep a state file after creating resources?
Terraform uses the state file to remember what it created (see execution_table step 4). This helps it know what exists and what needs updating or deleting later.
What happens if you change the resource config after creation?
Terraform compares the new config with the state (step 5). If different, it plans and applies updates to match the new config.
Why is the resource block important in Terraform?
The resource block tells Terraform exactly what to create or manage (step 1). Without it, Terraform doesn't know what infrastructure to handle.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the resource state after step 3?
AResource is planned to be created
BResource is created
CResource is deleted
DResource state is unknown
💡 Hint
Check the 'Resource State After' column in step 3.
At which step does Terraform update the state file to remove the resource?
AStep 4
BStep 5
CStep 7
DStep 6
💡 Hint
Look for 'State file updated, resource removed' in the 'Resource State After' column.
If you change the instance_type in the resource block, which step will detect this change?
AStep 2 - Plan execution
BStep 3 - Apply changes
CStep 5 - Next apply
DStep 6 - Destroy resource
💡 Hint
Terraform compares desired vs current state during planning (step 2).
Concept Snapshot
Terraform uses resource blocks to define cloud parts.
It reads these blocks, creates or updates resources,
and keeps track in a state file.
This state helps Terraform manage changes safely.
Resources are the core because they represent real infrastructure.
Full Transcript
Terraform's core is the resource block. It tells Terraform what cloud resource to create or manage. When you run Terraform, it reads these blocks, plans what to do by comparing current state and desired state, then applies changes to create or update resources. After creating, Terraform saves resource info in a state file to remember what exists. This helps it manage updates or deletions later. If you change the resource config, Terraform detects differences during planning and applies updates. When you destroy resources, Terraform deletes them and updates the state file. This cycle makes resources the heart of Terraform's infrastructure management.