terraform-iac

Author, review, test, and operate Terraform and OpenTofu infrastructure as code through a gated plan-apply lifecycle.

Updated Apr 11, 2026
One-click install
npx skills add https://github.com/lurodrisilva/personal-skills --skill terraform-iac-lurodrisilva
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: terraform-iac
Source: https://github.com/lurodrisilva/personal-skills/tree/main/platform-engineering/terraform-iac
Command: npx skills add https://github.com/lurodrisilva/personal-skills --skill terraform-iac-lurodrisilva

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Managing cloud and on-prem infrastructure by hand leads to configuration drift, unreviewed changes, and corrupted state. This Skill encodes the discipline of Infrastructure as Code with Terraform or OpenTofu: declarative HCL2 configuration, mandatory remote state with locking, least-privilege short-lived auth, and a plan → human review → gated apply lifecycle where every mutation is reviewed before it touches infrastructure. ## Core Features & Use Cases - Module Authoring: Build reusable, versioned modules with typed variables, validation blocks, outputs, for_each/count/dynamic, and safe moved-block refactors instead of copy-pasted resource blocks. - State, Providers & Plan Review: Configure remote backends with locking (S3+DynamoDB, azurerm, gcs, Terraform Cloud), pin providers via a committed .terraform.lock.hcl, authenticate with OIDC/assume-role/workload identity, and gate every apply behind plan review plus policy-as-code (OPA/Conftest/Sentinel). - Testing & Drift Detection: Wire fmt/validate/tflint/tfsec/checkov and native terraform test (.tftest.hcl) or terratest into CI as merge-blocking gates, and detect drift with plan -refresh-only reconciled through Git. - Use Case: A plan shows an unexpected destroy on a production database. The Skill's doctrine treats this as a stop-the-line event: read the saved plan, confirm prevent_destroy guards, pass the OPA policy gate, and apply only the reviewed plan through a PR approval. ## Quick Start Ask the AI to review your Terraform module for state backend safety, provider pinning, and plan-review gates before your next apply.

Frequently Asked Questions about terraform-iac

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely run terraform apply on shared infrastructure?▼

Save a plan with terraform plan -detailed-exitcode -out plan.bin, read it for destroys and replacements, pass a policy-as-code gate such as Conftest or OPA, then apply the saved plan through a PR or pipeline approval. Never use apply -auto-approve on shared infrastructure.

What Terraform backend should I use for remote state locking?▼

Use a remote backend with locking for any shared infrastructure: S3 with a DynamoDB lock table on AWS, azurerm with blob lease locking on Azure, gcs on GCP, or Terraform Cloud/HCP for remote runs and state. Local state is only tolerable for throwaway experiments.

Should I use for_each or count in Terraform modules?▼

Prefer for_each with stable keys for sets and maps of named resources, because reordering a count index can destroy and recreate the wrong resources. Reserve count for simple 0/1 toggles or genuinely ordered lists.

Does OpenTofu work with the same Terraform configuration and lockfile?▼

Yes. OpenTofu reads the same required_providers constraints and .terraform.lock.hcl, pulls the same providers from the OpenTofu registry, and mirrors plan -detailed-exitcode behavior. Commit the lockfile so both tools resolve identical provider versions.

How do I detect Terraform drift without changing infrastructure?▼

Run terraform plan -refresh-only -detailed-exitcode on a schedule; exit code 2 means real infrastructure no longer matches recorded state. Reconcile drift by updating HCL and re-applying through a PR, never by clicking in the cloud console.

When should I use Crossplane instead of Terraform?▼

Use Crossplane when you want Kubernetes-native, continuously reconciling control-plane IaC with XRDs, Compositions, and Managed Resources managed in-cluster. Terraform fits the client-side plan/apply archetype where changes flow through a reviewed, gated pipeline.