Posts

Day 9 - Terraform Lifecycle Meta Arguments in AWS

Image
Introduction In the previous days, I focused on creating resources using Terraform. Today was different. Day 09 helped me understand how Terraform manages changes over time. Instead of only creating infrastructure, I learned how to control what happens when something is updated, replaced, or removed. This is important because real environments are always changing. What are lifecycle meta arguments Lifecycle meta arguments allow us to control how Terraform behaves when it creates, updates, or destroys resources. They help us: Avoid downtime Protect important resources Handle changes made outside Terraform Validate configurations before and after deployment create before destroy By default, Terraform destroys a resource first and then creates a new one. With create before destroy, Terraform creates the new resource first and then removes the old one. Example lifecycle { create_before_destroy = true } This is useful when downtime is not acceptable, such as appl...

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