#IaC

9 posts

Terraform Basics #8 Module Basics: Reusing Resource Bundles and Registry Modules
5 min read

Terraform Basics #8 Module Basics: Reusing Resource Bundles and Registry Modules

Starting from the fact that every Terraform directory is already a module, we build a child module that takes variables as inputs and outputs as results, and call it with a module block. We also cover pulling battle-tested modules from the registry with version pinning, plus the criteria for splitting modules and where over-splitting begins.

Terraform Basics #7 Resource Lifecycle Control: Replacement Conditions, create_before_destroy, prevent_destroy
5 min read

Terraform Basics #7 Resource Lifecycle Control: Replacement Conditions, create_before_destroy, prevent_destroy

How to read from a plan which attribute changes end as an update and which ones force a resource replacement. We cover create_before_destroy, which flips the replacement order to reduce downtime, prevent_destroy, which blocks deletion of production resources, ignore_changes, which tolerates changes made outside the code, and forcing a replacement with the -replace flag.

Terraform Basics #6 Dependencies and Repetition: depends_on, count vs for_each, and dynamic Blocks
5 min read

Terraform Basics #6 Dependencies and Repetition: depends_on, count vs for_each, and dynamic Blocks

How references double as dependencies that decide creation order, and the exceptional cases where depends_on is needed. We cover the notorious recreation trap that removing an item from the middle of a list triggers with count, the key-based safety of for_each and how to choose between the two, and dynamic blocks for repeating nested blocks.

Terraform Basics #5 State Explained: The tfstate File Structure and How plan Computes Changes
5 min read

Terraform Basics #5 State Explained: The tfstate File Structure and How plan Computes Changes

Opening the terraform.tfstate file to examine its structure, and explaining how plan computes changes by comparing three things: code, state, and the real infrastructure. We also cover the problem of sensitive values stored in plaintext and the rule against committing state, manipulation commands like state list, show, mv, and rm, and what happens when you lose your state.

Terraform Basics #4 Data Sources and Expressions: Reading Instead of Creating, Conditionals, and for
5 min read

Terraform Basics #4 Data Sources and Expressions: Reading Instead of Creating, Conditionals, and for

Covering the data block that reads information from existing resources Terraform did not create, using a latest-AMI lookup as the example, then building per-environment branches with conditionals and transforming lists and maps with for expressions and splat syntax. We also go through the built-in functions you will use most and terraform console, the playground for trying expressions.

Terraform Basics #3 Variables, Outputs, and Locals: Three Tools for Removing Hardcoded Values
5 min read

Terraform Basics #3 Variables, Outputs, and Locals: Three Tools for Removing Hardcoded Values

How to pull values out of your code with variable blocks, and the precedence among the four input paths — tfvars files, the -var-file and -var flags, and environment variables. We block bad values at the door with validation, expose results with output, and name internal computations with locals, laying the groundwork for building multiple environments from the same code.

Terraform Basics #2 HCL Core Syntax: Blocks, Arguments, Resource Addresses, and the Three Shapes of Change
5 min read

Terraform Basics #2 HCL Core Syntax: Blocks, Arguments, Resource Addresses, and the Three Shapes of Change

A look at the skeleton of HCL — blocks and arguments — what a resource address like aws_s3_bucket.hello actually means, and the syntax for referencing one resource from another. We read the symbols in plan output to tell apart the three shapes of change — create, update, replace — and build the habit of running fmt and validate before every commit.

Terraform Basics #1 IaC and Terraform: Where Console Clicking Breaks Down, Installation, and the First apply
8 min read

Terraform Basics #1 IaC and Terraform: Where Console Clicking Breaks Down, Installation, and the First apply

Tracing how infrastructure built by clicking through the console falls apart — no reproducibility, no history, no review — and how declaring the desired state as code solves each of those problems. We compare where Terraform sits among CloudFormation, CDK, and Pulumi, then walk through installation and a first full cycle: creating an S3 bucket with init, plan, and apply, and removing it with destroy.

AWS in Practice #4: IaC — Terraform Fundamentals
10 min read

AWS in Practice #4: IaC — Terraform Fundamentals

Why IaC, Terraform shape of provider / resource / state, team collaboration with S3 + DynamoDB backend, environment separation through modules, and the flow of code-ifying the #1–#3 infrastructure line by line.