Posts

Day 7 - Type Constraints in Terraform

Image
Terraform has been feeling smooth so far. Define variables. Pass values. Resources get created. But today, I realized something important. Terraform is very trusting . And that can quietly become a problem. The moment it clicked Until now, I could pass almost anything as input. A string where a number was expected A wrong environment name like “testing” Even an invalid network CIDR Terraform wouldn’t complain immediately. The error would show up later… sometimes deep into execution. That’s not something you want when working on real infrastructure. What changed today Today was about type constraints . Instead of saying: “Give me some value” You start saying: “Give me exactly this type of value” That small shift adds a lot of control. Basic Types (simple, but powerful) Terraform supports three core types: string number bool At first glance, it feels basic. But defining these explicitly removes ambiguity. variables.tf showing: string numb...

Day 6 - Organizing Terraform Files the Right Way

Image
On Day 6, I learned something simple but powerful: Terraform code should not just work, it should also be easy to read. As projects grow, putting everything into a single main.tf file becomes messy. It may work for a small demo, but once more resources are added, it quickly becomes difficult to maintain. That is where file structure becomes important. Terraform reads all .tf files in the current directory as a single configuration. This means file names do not control the logic of the deployment. Instead, file names are there to help us organize the code better. Dependencies are handled through references between resources, not because one file comes before another. For this exercise, I split the configuration into multiple files: backend.tf for remote state configuration provider.tf for the AWS provider variables.tf for inputs locals.tf for reusable values vpc.tf for networking resources storage.tf for S3 resources outputs.tf for output values terraform.tf...

Day 5 - Terraform Variables

Image
  Content Today felt different. Terraform started feeling less like writing config and more like writing logic. Until now I was hardcoding values. Today I learned how to pass values, build them, and get them back using variables. There are 3 types Input variables Local variables Output variables At first it was confusing, but once I ran it myself, it made sense. What I built I created a simple S3 bucket using variables instead of hardcoding the name. To understand variables better, I created a small setup with multiple Terraform files. I used separate files for input variables, local values, main resource creation, and outputs. I also added tfvars files to test different environments like development and production. What I tested I tried a few things to understand how variables behave. First I ran normally using terraform.tfvars Terraform picked those values automatically Then I removed tfvars and ran again Terraform used default values from variables.tf Then ...

Day 4 - Terraform State File Management with Remote Backend

Image
Today felt different. Until now, Terraform was just creating resources. But today, I learned how Terraform remembers what it creates, and how to manage that memory safely using a remote backend. Why Remote State Matters When Terraform runs, it keeps track of infrastructure in a state file. If that file stays on a local machine: It’s not shareable It’s not safe It can easily get corrupted or lost Moving state to Amazon S3 solves this. Teams can collaborate State is stored securely Changes are tracked with versioning Locking prevents conflicts What I Built Today I configured Terraform to: Store state in an S3 bucket Enable encryption Use native state locking (no DynamoDB required) Create a new S3 bucket using Terraform Step 1: Created S3 Bucket for State I manually created an S3 bucket and enabled versioning. Step 2: Configured Remote Backend I updated my Terraform configuration to use S3 as backend: backend "s3" { bucket =...

Day 3 - Creating My First S3 Bucket Using Terraform

Image
  Introduction Day 3 felt like the first real interaction with AWS. Not just writing Terraform code,  but actually creating something in the cloud. A small step, a simple S3 bucket, but it carried an important lesson: before infrastructure, comes authentication. Understanding the Basics Before Terraform can create anything in AWS, it needs permission. This is handled using AWS credentials. I configured mine using: aws configure Once set, Terraform can securely communicate with AWS APIs. What is S3? Amazon S3 (Simple Storage Service) is an object storage service. It allows you to store files like: Images Backups Logs Application data One key rule: S3 bucket names must be globally unique across AWS. Terraform Code Here’s the simple configuration I used: provider "aws" { region = "us-east-1" } resource "aws_s3_bucket" "my_bucket" { bucket = "jay-day3-s3-bucket-123456" tags = { Name = "Day3B...

Day 2 – Terraform Providers and Versioning Explained with Real AWS Deployment

Image
  Introduction On Day 2 of my 30-Day AWS Terraform Challenge, I moved from understanding concepts to actually running Terraform against AWS. This day focused on Terraform Providers, versioning, and why controlling versions is critical when working with Infrastructure as Code. More importantly, I successfully created real AWS resources using Terraform. AWS Configuration Before running Terraform, I configured AWS CLI to allow my local environment to connect to my AWS account. First, I installed AWS CLI and verified it. Then I configured credentials as below.  This confirmed that my local machine was successfully authenticated with AWS. What are Terraform Providers Terraform providers act as a bridge between Terraform and external systems like AWS. Terraform itself does not directly create resources. Instead, it uses providers such as the AWS provider to communicate with cloud APIs. For AWS, the provider used is hashicorp/aws . Terraform Core vs Provider Version O...