Posts

Day 8 - Understanding Meta Arguments

Image
Today was Day 08 of my AWS Terraform challenge. The topic was Terraform meta arguments. At first, this topic was not very clear to me because there were several new concepts like count, for_each, depends_on, lifecycle, provider, and for expressions. After practicing with simple S3 bucket examples, I understood how powerful these are. What are Meta Arguments Meta arguments are special arguments in Terraform that can be used with any resource to control how it behaves. Instead of writing multiple resource blocks, we can use these to create and manage resources efficiently. Folder Structure Used Day 08 folder structure in VS Code I used the following files: backend.tf provider.tf variables.tf locals.tf main.tf outputs.tf terraform.tfvars Understanding count count is used when we want to create multiple similar resources using numbers. variables.tf showing count_buckets main.tf showing count block Terraform creates resources like: aws_s3_bucket.count_demo[0] aws_s3_bucket.count_demo...

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 ...