AWS Builder Center
Terraform on AWS: The Basics Every DevOps Engineer Should Master

Terraform on AWS: The Basics Every DevOps Engineer Should Master

A hands-on walkthrough of init, plan, apply, and show — the four commands that power Infrastructure as Code on AWS.

Why Terraform?

Manually clicking through the AWS Console to create a VPC, subnets, EC2 instances, and an RDS database works — once. The problem starts the second time: environments drift, mistakes creep in, and nobody remembers exactly what was clicked six months ago.
Terraform solves this by letting you describe your infrastructure as code: version-controlled, reviewable, and 100% reproducible. Instead of "I think I created the VPC with these settings," you get a  .tf  file that is the source of truth.
In this article, I'll walk through the core Terraform workflow using a real example: provisioning a VPC, an EC2 subnet, and an RDS instance on AWS — the same four commands you'll use on virtually every Terraform project.The Terraform Workflow: 4 Commands, 1 Loop
terraform init → terraform plan → terraform apply → terraform show / output

1.  terraform init  — Initialize the working directory

This is always the first command you run in a new Terraform project. It downloads the required provider plugins (here, the AWS provider) and sets up the backend.
$ terraform init
terraform init

Terraform confirms it has downloaded the AWS provider and initialized the backend. From here, every other command becomes available.

2.  terraform plan  — Preview before you touch anything

 terraform plan  is arguably the most important habit in IaC. It computes a dry-run diff between your code and the real infrastructure state — showing exactly what will be created, changed, or destroyed, before anything actually happens.
$ terraform plan
terraform plan

In this example, the plan shows  12 to add, 0 to change, 0 to destroy  — a fresh deployment of a VPC and its associated resources. Reading this output carefully before applying is what separates a controlled deployment from a surprise outage.

3.  terraform apply  — Provision the real infrastructure

$ terraform apply
terraform apply

Notice how the RDS instance took several minutes ("Still creating... [5m6s elapsed]") — a good reminder that not everything in AWS provisions instantly, and Terraform patiently polls the API until the resource reports  available . The run finishes with  Apply complete! Resources: 12 added, 0 changed, 0 destroyed , plus the declared outputs (subnet ID, RDS endpoint, VPC ID — masked here for security).

4.  terraform show  /  terraform output  — Inspect what you built

Once applied, you don't need to open the AWS Console to check what was created — Terraform already knows, because it tracks everything in its state file.
$ terraform show
$ terraform output
terraform show

 terraform show  dumps the full resource attributes as Terraform sees them (ARN, CIDR block, security group ID, route table ID, and more).  terraform output  prints only the values you explicitly declared as outputs — handy for feeding into scripts or other tools.

Key Takeaways

 init  sets up your working directory and providers — run it once per project (and again after adding new providers/modules).
 plan  is your safety net — always read it before applying, especially in shared or production environments.
 apply  is the only command that touches real infrastructure — treat it with the same care as a production deployment, because it is one.
 show  and  output  let you verify and reuse what you built without leaving the terminal.
Terraform's state file is what makes all of this possible — it's the map between your code and the real world, and it deserves to be protected (remote backend + state locking) just as much as your source code.
What's Next
This walkthrough covers the fundamentals — a single VPC, subnet, and RDS instance — but it's the same foundation I'm building on for a larger project: an AWS environment designed to support an autonomous DevOps agent. A few concrete next steps on that path:
  • Splitting this configuration into reusable modules (network, compute, database) instead of one flat file
  • Storing state remotely (S3 backend + DynamoDB lock table) instead of locally, to make it team-safe
  • Adding  terraform validate  and  terraform fmt  to a CI pipeline so every change is checked before merge
  • Layering CloudWatch alarms on top of this infrastructure as the monitoring foundation for the next stage of the project
Terraform's core loop —  init → plan → apply → verify  — doesn't change whether you're deploying a single VPC or a hundred resources across multiple environments. Master this loop, and everything else in Infrastructure as Code is just composition on top of it.


This is part of a broader journey into AWS and AIOps — more articles on the automation and monitoring layers built on top of this infrastructure are coming soon. Questions or feedback on this setup are welcome.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article