Skip to content
Back to skills

Iac Terraform

ASecurity

Terraform/OpenTofu — remote state, modules, CI/CD, drift detection.

  • 6 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 5, 2026
ai-agentsbashawsgcpazureterraformgitbackendci/cd

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add Dev-Toolbelt/dev-team-agents --skill iac-terraform --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Iac Terraform?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Iac Terraform
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dev-toolbelt-iac-terraform/badge)](https://www.skillsdirectory.com/skills/dev-toolbelt-iac-terraform)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: iac-terraform
description: Terraform/OpenTofu — remote state, modules, CI/CD, drift detection.
---

# Infrastructure as Code — Terraform / OpenTofu

## Core Principle

IaC is code. It lives in git, gets reviewed in PRs, runs in CI, and never has secrets hardcoded in it. State is shared and locked.

> OpenTofu is a drop-in open-source alternative to Terraform. All patterns here apply to both.

---

## Detection Signals

| Signal | Location |
|--------|----------|
| `*.tf` files | `infra/` or repo root |
| `terraform.tfvars` | environment directories |
| `.terraform.lock.hcl` | environment directories |
| `hashicorp/setup-terraform` | CI/CD pipeline files |
| `TF_VAR_*` env vars | `.env`, CI secrets |

---

## Core Workflow

```bash
terraform init      # initialize backend and download providers
terraform validate  # check syntax and provider references
terraform plan      # preview changes — always review before apply
terraform apply     # apply changes (never skip plan in production)
terraform destroy   # destroy resources (requires explicit approval)
```

**Never run `apply` without reviewing `plan` output in production.**

---

## Key Rules (apply always)

| Rule | Detail |
|------|--------|
| Remote state | Always use remote backend with locking — never local state in teams |
| Secrets | Use cloud secret manager data sources — never in `.tfvars` or `-var` flags |
| Modules | Create when same resources used in 2+ environments |
| Version pins | Pin module versions via git tags; pin provider versions in `required_providers` |
| `for_each` over `count` | Use `for_each` with maps for resources that differ significantly |
| CI apply gates | Manual approval required for production environments |

Load `references/patterns.md` for: full project structure, remote state backend configs (AWS/GCP/Azure), module patterns, variable validation, secrets data sources, import commands, and anti-patterns.

Load `references/ci-cd.md` for: GitHub Actions plan/apply/drift-detection workflows, GitLab CI plan+apply pipeline, environment promotion pattern.

---

## `.gitignore` Requirements

```
*.tfstate
*.tfstate.backup
.terraform/
*.tfplan
```

---

## Before Declaring Done

- [ ] Remote backend configured with state locking (S3+DynamoDB, GCS, or Azure Blob)
- [ ] State bucket has versioning enabled (allows rollback)
- [ ] No secrets in `.tfvars` or passed via `-var` — all secrets use data sources
- [ ] `terraform validate` passes in CI on every PR
- [ ] `terraform plan` output posted to PR for review
- [ ] `terraform apply` requires manual approval for production environment
- [ ] Drift detection scheduled (weekly minimum)
- [ ] `.gitignore` includes `*.tfstate`, `.terraform/`, `*.tfplan`
- [ ] Modules versioned via git tags if shared across repos

Files in this skill

  • SKILL.md2.7 KB
  • references/ci-cd.md4.1 KB
  • references/patterns.md4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.