0
0
Terraformcloud~10 mins

Terraform apply for execution - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Terraform apply for execution
Write Terraform config
terraform init
terraform plan
terraform apply
Resources created/updated
terraform state updated
Infrastructure ready
This flow shows how Terraform applies configuration to create or update cloud resources, updating the state to reflect changes.
Execution Sample
Terraform
resource "aws_s3_bucket" "example" {
  bucket = "my-unique-bucket-12345"
  acl    = "private"
}

terraform apply
This code creates a private AWS S3 bucket named 'my-unique-bucket-12345' when 'terraform apply' is run.
Process Table
StepActionEvaluationResult
1Read Terraform configParse resource blockResource aws_s3_bucket.example identified
2terraform initInitialize backend and providersProviders downloaded, backend configured
3terraform planCompare desired state with current statePlan shows 1 resource to add
4terraform apply - confirmUser confirms applyApply starts
5Create aws_s3_bucket.exampleSend API request to AWSBucket created successfully
6Update terraform stateRecord new resource in state fileState updated with aws_s3_bucket.example
7Apply completeNo errorsInfrastructure matches config
💡 All resources created successfully, terraform state updated, apply finished
Status Tracker
VariableStartAfter Step 3After Step 6Final
terraform_stateemptyshows planned resourceincludes aws_s3_bucket.examplefinal with created resource
resource_statusnot createdplanned to createcreatedcreated
Key Moments - 3 Insights
Why does terraform plan show changes before apply?
terraform plan compares current state with config and shows what will change; see execution_table step 3.
What happens if user does not confirm apply?
Apply stops before making changes; no resources created; see execution_table step 4.
How does terraform know what resources exist after apply?
It updates the state file after successful creation; see execution_table step 6.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step is the AWS bucket actually created?
AStep 3
BStep 5
CStep 6
DStep 7
💡 Hint
Check the 'Action' and 'Result' columns in execution_table row 5.
According to variable_tracker, what is the state of 'resource_status' after step 3?
Aplanned to create
Bnot created
Ccreated
Ddeleted
💡 Hint
Look at 'resource_status' value under 'After Step 3' in variable_tracker.
If the user declines confirmation at step 4, what happens to the terraform state?
AState is updated with new resource
BState is deleted
CState remains unchanged
DState is partially updated
💡 Hint
Refer to key_moments about user confirmation and execution_table step 4.
Concept Snapshot
Terraform apply runs after init and plan.
It creates or updates resources to match config.
User confirmation is required before changes.
State file updates after successful apply.
Apply stops if user declines confirmation.
Full Transcript
Terraform apply is the command that makes your cloud resources match your configuration. First, you write your config file describing resources like an AWS S3 bucket. Then you run 'terraform init' to prepare providers. Next, 'terraform plan' shows what changes will happen. When you run 'terraform apply', Terraform asks for confirmation. After you confirm, it creates or updates resources by calling cloud APIs. Once done, it updates the state file to remember what exists. If you do not confirm, no changes happen. This process ensures your cloud matches your desired setup safely and clearly.