GeekCoding101

  • Home
  • GenAI
    • Daily AI Insights
    • Machine Learning
    • Transformer
    • Azure AI
  • DevOps
    • Kubernetes
    • Terraform
  • Tech
    • CyberSec
    • System Design
    • Coding Notes
  • About
  • Contact
aws
Terraform

Terraform Meta Arguments Unlocked: Practical Patterns for Clean Infrastructure Code

I’ve always found Terraform meta arguments a bit confusing at first glance—not count, for_each, but things like connection, provisioner, depends_on, source and lifecycle often seem straightforward but can behave unexpectedly in different contexts. That’s why I decided to write this blog post: to break them down clearly, explain what each one does, and show practical examples of how and when to use them effectively. Terraform Meta Arguments Table   Meta-Argument Applicable To Description count resource, module, data Create multiple instances of a resource or module using a number. for_each resource, module, data Create multiple instances using a map or set of strings. More flexible than count. provider resource Specify which provider configuration to use if multiple are defined. depends_on resource, module, data Explicitly define dependencies between resources or modules. lifecycle resource Control resource creation and destruction behavior (e.g., prevent_destroy, ignore_changes). provisioner resource Run scripts or commands after a resource is created or destroyed. connection resource Define how to connect to a remote resource (used with provisioners). source module Specify the location of a module (registry, Git, local path, etc.). Usage 🧮 Terraform meta arguments: count resource "aws_instance" "web" { count = 3 ami = "ami-0c55b159cbfafe1f0" instance_type = "t2.micro" tags = { Name = "Web-${count.index}" } } ✅ Creates multiple instances using a simple integer. ⚠️ Attention Notes: count.index starts from 0. Not ideal for working with named collections (use for_each instead). Not supported in provider blocks. 🔁 Terraform meta arguments: for_each   resource "aws_s3_bucket" "example" { for_each = toset(["logs", "media", "backups"]) bucket = "my-bucket-${each.key}" acl = "private" } ✅ More flexible…

April 20, 2025 0comments 109hotness 0likes Geekcoding101 Read all
Terraform

Mastering Terraform with AWS Guide Part 1: Launch Real AWS Infrastructure with VPC, IAM and EC2

So… you’ve heard about Terraform. Maybe your team is using it, maybe your cloud dreams demand it — or maybe, like me, you’ve been deep in the Kubernetes jungle (My blog posts about K8S) and now want a declarative friend for AWS too! Either way, welcome aboard. In this post, I’ll walk you through setting up your Terraform with AWS environment from scratch, on a Mac. We’ll start simple and go all the way to managing VPC, Security Groups, IAM users and EC2 infrastructure using best practices -all built using Terraform with AWS. By the end, you’ll not only run Terraform with AWS  — you’ll understand all below questions, just to name a few, such as how to run terraform with aws, how to create aws ec2 instance using terraform, how to create security group in aws using terraform...fantastic! What is Terraform? Terraform is an open-source infrastructure as code (IaC) tool created by HashiCorp. It lets you define, provision, and manage cloud infrastructure using human-readable config files written in HCL (HashiCorp Configuration Language). Think of it as Git for your cloud — but with superpowers. I know it's kind of short introduction, let's look at a real life scenario to understand what it is and why we need it! Why Do We Actually Need Terraform? A Real-Life Scenario Let’s say you’re an ambitious DevOps engineer named Alice. One day your boss comes in hot: “Hey Alice! We need 3 EC2 instances on AWS, 2 on Azure, and an S3 bucket for backups. Oh — and don’t forget a VPC, IAM…

April 15, 2025 0comments 99hotness 0likes Geekcoding101 Read all
Newest Hotest Random
Newest Hotest Random
Secure by Design Part 1: STRIDE Threat Modeling Explained Kubernetes Control Plane Components Explained A 12 Factor Crash Course in Python: Build Clean, Scalable FastAPI Apps the Right Way Golang Range Loop Reference - Why Your Loop Keeps Giving You the Same Pointer (and How to Fix It) Terraform Associate Exam: A Powerful Guide about How to Prepare It Terraform Meta Arguments Unlocked: Practical Patterns for Clean Infrastructure Code
A 12 Factor Crash Course in Python: Build Clean, Scalable FastAPI Apps the Right WayKubernetes Control Plane Components ExplainedSecure by Design Part 1: STRIDE Threat Modeling Explained
Diving into "Attention is All You Need": My Transformer Journey Begins! Terms Used in "Attention is All You Need" Transformers Demystified - Day 2 - Unlocking the Genius of Self-Attention and AI's Greatest Breakthrough Vue: Secrets to Resolving Empty index.html in WebHistory Build and Sign RPM package and repo Supervised Machine Learning - Day 1
Newest comment
Tag aggregation
Daily.AI.Insight Machine Learning Transformer AI Supervised Machine Learning cybersecurity security notes

COPYRIGHT © 2024 GeekCoding101. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang