devops

Terraform flatten with Nested Maps and for_each

Flatten nested Terraform maps into for_each-ready keyed maps on Ubuntu — nested for expressions, flatten list of lists, stable composite keys, terraform_data instances, state addresses, key stability when input shrinks, …

Deepak Prasad11 min read
devops

Terraform Optional Object Attributes and Defaults

Use Terraform optional() inside object type constraints on Ubuntu — required vs optional attributes, default values, nested optional objects, omitted vs explicit null, map(object) inputs, tfvars overrides, and common …

Deepak Prasad15 min read
devops

Terraform "(known after apply)" Explained

Understand Terraform known after apply on Ubuntu — normal computed unknowns in plan output, when unknown values break count and for_each, static map keys with apply-time values, deferred data sources, module output …

Deepak Prasad10 min read
devops

Fix Terraform "Attempt to Get Attribute from Null Value"

Fix Terraform Attempt to get attribute from null value on Ubuntu — null parent object access, optional attributes versus entire object null, default empty object patterns, conditional and try guards, nested null parents, …

Deepak Prasad14 min read
devops

Fix Terraform "Saved Plan Is Stale" Error

Fix Terraform Saved plan is stale on Ubuntu — reproduce stale saved plan after state serial changes, distinguish lineage mismatch errors, regenerate plan -out before apply, CI race causes, locking and concurrency …

Deepak Prasad10 min read
devops

Fix Terraform Undeclared Variable Errors

Fix Terraform undeclared variable errors on Ubuntu — Reference to undeclared input variable versus Value for undeclared variable, missing variable blocks, extra terraform.tfvars keys, -var and -var-file mistakes, module …

Deepak Prasad10 min read
devops

Fix Terraform "Error: Cycle" Dependency Error

Fix Terraform Error Cycle on Ubuntu — mutual resource references, module dependency loops, unnecessary depends_on chains, terraform graph with draw-cycles, breaking cycles with locals and one-direction flow, and …

Deepak Prasad10 min read
devops

Fix Terraform "Provider Configuration Not Present" Error

Fix Terraform Provider configuration not present on Ubuntu — state bound to removed provider aliases, module providers map and configuration_aliases, safe restore-destroy-remove sequence, related missing-provider errors, …

Deepak Prasad11 min read
devops

Terraform CI/CD Pipeline with GitHub Actions

Build a Terraform CI/CD pipeline with GitHub Actions on Ubuntu — run terraform fmt check, validate and plan non-interactively with TF_IN_AUTOMATION and TF_INPUT, save and apply a reviewed plan file, protect concurrent …

Deepak Prasad40 min read
devops

Fix Terraform "Inconsistent Dependency Lock File" Error

Fix Terraform Inconsistent dependency lock file on Ubuntu — configuration versus .terraform.lock.hcl mismatch, no version is selected errors, init versus init -upgrade, saved plan and lock drift, CI artifact handling, …

Deepak Prasad11 min read
devops

Fix Terraform "Unsupported Attribute" Error

Fix Terraform Unsupported attribute on Ubuntu — wrong object keys, missing module outputs, count and for_each module shape changes, terraform_remote_state output typos, terraform console diagnostics with type and keys, …

Deepak Prasad12 min read
devops

Fix Terraform "Invalid Index" Error

Fix Terraform Invalid index on Ubuntu — missing map keys, list index out of range, empty tuple from conditional resources, count.index mismatches, for_each module addressing, terraform console diagnostics, and safer …

Deepak Prasad11 min read
devops

Fix Terraform "Invalid for_each Argument" Error

Fix Terraform Invalid for_each argument on Ubuntu — wrong list or tuple type, toset and map conversion, keys known only after apply, map of objects with each.key, nested list flattening, duplicate keys, and verification …

Deepak Prasad14 min read
devops

Terraform Test Framework with Examples

Learn the Terraform test framework on Ubuntu with terraform test — write .tftest.hcl files with run blocks and assert conditions, compare plan versus apply tests, pass test variables, mock providers without cloud …

Deepak Prasad16 min read
devops

terraform console Command with Examples

Learn the terraform console command on Ubuntu — evaluate expressions and functions interactively, inspect variables, locals and resource attributes from state, read unknown values with -plan, pipe expressions …

Deepak Prasad23 min read
devops

terraform graph: Visualize Terraform Dependencies

Generate and render Terraform dependency graphs on Ubuntu with terraform graph and Graphviz — read DOT output, pipe to SVG or PNG, compare implicit references with explicit depends_on, inspect module clusters, and use …

Deepak Prasad12 min read
devops

Migrate Local Terraform State to HCP Terraform

Move an existing locally managed Terraform state into an HCP Terraform workspace from Ubuntu — verify healthy local state, back it up, add a cloud block to an empty destination workspace, answer the migration prompt …

Deepak Prasad16 min read
devops

Terraform Troubleshooting Guide

Diagnose Terraform failures on Ubuntu by isolating the stage that broke — triage commands, terraform init and plan errors, partial apply recovery, provider and authentication failures, state lock and backend problems, …

Deepak Prasad24 min read
devops

Terraform Logging and Debugging with TF_LOG

Learn Terraform debug logs on Ubuntu — turn on TF_LOG, compare TRACE, DEBUG, INFO, WARN and ERROR volume, persist output with TF_LOG_PATH, split Terraform Core from provider logs with TF_LOG_CORE and TF_LOG_PROVIDER, …

Deepak Prasad24 min read
devops

Terraform Import: Import Existing Infrastructure

Learn Terraform import on Ubuntu — bring existing infrastructure under Terraform management with the terraform import CLI, declarative import blocks, generated configuration, for_each imports, module addresses, and plan …

Deepak Prasad26 min read
devops

Terraform Workspaces with Examples

Learn Terraform CLI workspaces on Ubuntu — workspace list, new, select, show, delete, terraform.workspace in configuration, local state layout, when to use workspaces, and how they differ from HCP Terraform workspaces on …

Deepak Prasad13 min read
devops

Terraform Drift Detection and Refresh-Only Mode

Learn Terraform drift detection on Ubuntu — out-of-band Docker changes, normal terraform plan, plan and apply -refresh-only, state vs configuration vs remote objects, deprecated terraform refresh, ignore_changes …

Deepak Prasad10 min read
devops

Terraform moved and removed Blocks with Examples

Learn Terraform moved and removed blocks on Ubuntu — rename resources, move into modules, stop managing without destroy, moved vs state mv, removed vs state rm, for_each address changes, and before-after plan evidence on …

Deepak Prasad10 min read
devops

Terraform State Commands with Examples

Learn terraform state commands on Ubuntu — state list, show, mv, rm, pull, and push with resource addresses, backup before modification, rm vs destroy, mv vs moved blocks, and push lineage warnings on Terraform 1.15.8.

Deepak Prasad11 min read
devops

Terraform State Locking and force-unlock

Learn Terraform state locking on Ubuntu — why backends lock state, reproduce Error acquiring the state lock, read lock ID metadata, safely use terraform force-unlock, lock-timeout and lock false risks, and current S3 …

Deepak Prasad11 min read
devops

Terraform Backends and Remote State Explained

Learn Terraform backends and remote state on Ubuntu — default local backend, backend block syntax, terraform init -reconfigure vs -migrate-state, partial backend configuration, locking overview, terraform_remote_state, …

Deepak Prasad15 min read
devops

Terraform Module Sources and Version Constraints

Learn Terraform module sources on Ubuntu — local paths, Registry addresses, Git ref pinning, subdirectory syntax, version constraints, terraform init and init -upgrade, terraform modules, provider vs module versioning, …

Deepak Prasad13 min read
devops

Terraform Module Inputs and Outputs with Examples

Learn how data crosses Terraform module boundaries on Ubuntu — child inputs, module arguments, outputs, module.NAME.OUTPUT references, chaining modules, implicit dependencies, providers mapping, sensitive propagation, …

Deepak Prasad11 min read
devops

Terraform Registry Modules: Find and Use Public Modules

Learn Terraform Registry modules on Ubuntu — public module source addresses, documentation evaluation, cloudposse label null module lab, terraform init, terraform modules, .terraform/modules inspection, upgrade and …

Deepak Prasad9 min read
devops

Terraform Modules: Create and Use Local Modules

Learn Terraform modules on Ubuntu — root vs child module, local module structure, module block syntax, variables and outputs across module boundaries, calling the same module twice, state addresses, init after module …

Deepak Prasad10 min read