Skip to main content

Command Palette

Search for a command to run...

🚀 Terraform with AWS – Day 02: Providers, Resources & Variables

Published
2 min read
🚀 Terraform with AWS – Day 02: Providers, Resources & Variables
A

Tech-driven, cloud-focused, and growth-minded ☁️ Building skills in cloud engineering with a DevOps base. Passionate about learning and solving real problems.


Yesterday, I kicked off my Terraform journey by installing it and launching my very first EC2 instance.
👉 Today, I went deeper and explored Providers, Resources, and Variables in Terraform.

By the end of the day, I had provisioned both an EC2 instance and an S3 bucket using clean and reusable code. Let’s walk through it!


🔹 What are Providers?

A provider allows Terraform to talk to a specific platform (like AWS, GCP, or Azure).
Since I’m working with AWS, I used the AWS provider:

provider "aws" {
  region = var.region
}

This tells Terraform to work with AWS in the specified region.


🔹 What are Resources?

A resource defines something we want Terraform to create or manage.
Examples:

  • EC2 instance

  • S3 bucket

  • IAM user

Here’s an EC2 instance resource:

resource "aws_instance" "example" {
  ami           = "ami-08c40ec9ead489470"
  instance_type = var.instance_type

  tags = {
    Name = "Terraform-Instance-Variables"
  }
}

And here’s an S3 bucket resource:

resource "aws_s3_bucket" "my_bucket" {
  bucket = "abdul-terraform-bucket-12345"
  acl    = "private"
}

🔹 Why Use Variables?

Instead of hardcoding values, Terraform lets us define variables for flexibility.

variable "region" {
  default = "us-east-1"
}

variable "instance_type" {
  default = "t2.micro"
}

👉 Now, I can change regions or instance types without touching the main code.


▶️ Terraform Commands I Used

Here are the 5 essential commands I practiced today:

1️⃣ terraform init

Initializes the project and downloads required providers.

terraform init

2️⃣ terraform validate

Checks if the code is syntactically valid.

terraform validate

3️⃣ terraform plan

Previews what Terraform will do before making changes.

terraform plan

4️⃣ terraform apply

Applies the configuration and creates infrastructure.

terraform apply

5️⃣ terraform destroy

Destroys all resources when no longer needed.

terraform destroy

💡 Key Takeaways from Day 02

✅ Providers connect Terraform with cloud platforms like AWS.
✅ Resources define the infrastructure we want to manage.
✅ Variables make code flexible & reusable.
✅ Learned 5 core commands: init, validate, plan, apply, destroy.


🔗 Follow My Journey


✨ That’s the end of Day 02. Tomorrow, I’ll dive deeper into Terraform state management and best practices. Stay tuned!

More from this blog

T

The Cloud Engineer’s Log

36 posts

A practical logbook of cloud engineering—architecture, infrastructure as code, automation, and real-world problem solving in modern cloud environments.