Terraform
Basics & Fundamentals
- Infrastructure as Code (IaC)
- Declarative Syntax in IaC
- Terraform Configuration Files
- Terraform CLI
- Terraform Init
- Terraform Plan
- Terraform Apply
- Terraform Destroy
Providers & Resources
Variables & Outputs
- Input Variables
- Variable Types
- Default Values
- Environment Variables
- Output Values
- Variable Validation
State Management
- Terraform State File
- Terraform Remote State
- Terraform State Locking
- Terraform Drift Detection
- Terraform Refresh
- Terraform Import
Modules (Reusability)
- Terraform Modules
- Terraform Public Modules
- Terraform local modules
- Terraform Module Versioning
- Terraform Nested Modules
Provisioners & Lifecycle
๐ Terraform Apply: Executing Plans and Creating Real Infrastructure
If terraform plan is like a blueprint for infrastructure, then terraform apply is the construction crew that brings the blueprint to life.
The Terraform Apply command executes the changes defined in your configuration files (.tf) and creates, updates, or deletes cloud resources as per the plan.
๐ In other words:
- terraform plan= What Terraform will do.
- terraform apply= Actually doing it.
Without terraform apply, no infrastructure would ever be deployed. Itโs the command that turns Infrastructure as Code (IaC) into real-world infrastructure.
โ๏ธ What Does Terraform Apply Do?
When you run:
terraform applyTerraform performs:
- 
Reads Configurations ( .tffiles)- Analyzes what resources are requested.
 
- 
Loads State File ( terraform.tfstate)- Compares current infrastructure with desired state.
 
- 
Creates Execution Plan - Proposes changes (like terraform plan).
 
- Proposes changes (like 
- 
User Approval (unless auto-approved) - 
Prompts: Do you want to perform these actions?Only 'yes' will be accepted to approve.
 
- 
- 
Applies Changes - Creates, updates, or deletes resources.
 
- 
Updates State File - Saves the new state of the infrastructure.
 
๐ Terraform Apply Syntax & Options
Basic usage:
terraform applyUseful flags:
- 
terraform apply -auto-approveSkip approval prompt (use carefully in CI/CD).
- 
terraform apply plan.outApply a previously saved plan for consistent deployments.
- 
terraform apply -refresh=falseSkip refreshing state before apply.
- 
terraform apply -varor-var-fileInject variables when applying.
๐ 3 Unique Real-World Examples of Terraform Apply
โ Example 1: Deploying an AWS S3 Bucket
main.tf
provider "aws" {  region = "us-east-1"}
resource "aws_s3_bucket" "example" {  bucket = "terraform-apply-example-bucket"  acl    = "private"}Run Commands:
terraform initterraform planterraform applyExpected Output:
aws_s3_bucket.example: Creating...aws_s3_bucket.example: Creation complete after 3sApply complete! Resources: 1 added, 0 changed, 0 destroyed.๐ The bucket is now live in AWS.
โ Example 2: Updating an Existing Resource
Modify bucket ACL:
resource "aws_s3_bucket" "example" {  bucket = "terraform-apply-example-bucket"  acl    = "public-read"}Run Apply:
terraform applyOutput:
aws_s3_bucket.example: Modifying...~ acl: "private" โ "public-read"Apply complete! Resources: 0 added, 1 changed, 0 destroyed.๐ terraform apply updated the ACL without recreating the bucket.
โ Example 3: Destroying Resources
Remove S3 bucket block from main.tf.
Run Apply:
terraform applyOutput:
aws_s3_bucket.example: Destroying...aws_s3_bucket.example: Destruction complete after 2sApply complete! Resources: 0 added, 0 changed, 1 destroyed.๐ Deleting the block in code + running terraform apply removes the resource from AWS.
๐ฏ Why is Terraform Apply Important?
- 
Turns Code into Reality - Converts .tfcode into running infrastructure.
 
- Converts 
- 
Ensures Consistency - Keeps infrastructure aligned with code (no drift).
 
- 
Automates Infrastructure Deployment - Eliminates manual provisioning steps.
 
- 
Supports Continuous Delivery - Easily integrated with CI/CD pipelines.
 
- 
Auditable & Predictable - Execution is logged and state files maintain history.
 
๐ง How to Remember Terraform Apply (Exam & Interview)
Mnemonic: A.C.E
- A โ Apply changes
- C โ Create/update/destroy resources
- E โ Execute the plan
๐ Interview Answer: โTerraform apply takes the execution plan and applies it, creating, modifying, or deleting resources as needed. Itโs the command that executes Infrastructure as Code.โ
๐ Best Practices for Terraform Apply
- Always run terraform planfirst.
- Use -auto-approveonly in CI/CD pipelines, never manually.
- Apply saved plans (plan.out) for reproducibility.
- Use remote backends (S3, Azure Blob, GCS) for collaborative apply.
- Review apply logs carefully, especially in production.
๐ฎ Future Enhancements of Terraform Apply
- Policy enforcement โ Built-in compliance checks before apply.
- AI-based warnings โ Detect potentially risky actions.
- Visual apply previews โ Show graphical representation of resource changes.
- Rollback capability โ Undo failed applies more easily.
๐ Summary
- 
terraform applyis the command that executes your infrastructure plan.
- 
It creates, updates, or destroys resources to match .tffiles.
- 
Steps: - Reads config โ Compares state โ Proposes changes โ Awaits approval โ Executes.
 
- 
Symbols: - +Resource created
- ~Resource updated
- -Resource destroyed
 
- 
Remember with A.C.E โ Apply, Create, Execute. 
โ Final Takeaway
Without terraform apply, Terraform would be just a planning tool. Itโs the command that transforms your code into infrastructure reality.
- For beginners, itโs how you bring your first S3 bucket, VM, or network to life.
- For DevOps engineers, itโs the backbone of automated pipelines.
- For enterprises, it ensures scalable, predictable, and secure deployments.
๐ In short: Terraform Apply = Infrastructure Creation in Action.