terraform-module

Generates reusable Terraform modules with variables, outputs, remote state, and CI/CD integration.

1|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts --skill terraform-module-kalilurrahman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: terraform-module
Source: https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts/tree/main/02-devops-infra/terraform-module
Command: npx skills add https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts --skill terraform-module-kalilurrahman

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing infrastructure as code from scratch for every environment leads to duplicated HCL, inconsistent tagging, and unsafe state management. This Skill produces properly structured Terraform modules with validation, remote state backends, and multi-environment configuration. ## Core Features & Use Cases - Module Structure: Generates complete module layouts with main.tf, variables.tf, outputs.tf, versions.tf, and nested submodules. - State Management: Configures S3 remote backends with DynamoDB locking, encryption, and versioning for team collaboration. - Multi-Environment Deployment: Creates per-environment tfvars files for dev, staging, and production with isolated state. - CI/CD Integration: Provides GitHub Actions workflows running terraform fmt, validate, plan on pull requests, and apply on merge. - Use Case: A platform engineer needs a versioned AWS VPC module with public/private subnets and NAT gateways, deployed consistently across dev and prod with state locking and automated plan checks in CI. ## Quick Start Ask the AI to generate a Terraform module for an AWS VPC with remote S3 state, variable validation, and separate dev and prod tfvars files.

Frequently Asked Questions about terraform-module

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

FAQPage Schema
How do I structure a reusable Terraform module?

A reusable Terraform module separates concerns into main.tf for resources, variables.tf for typed inputs with validation blocks, outputs.tf for exported resource IDs, and versions.tf for provider constraints. Include examples/ and nested modules/ directories for composition.

How to set up Terraform remote state with S3 and DynamoDB?

Configure an S3 backend block in backend.tf pointing to a versioned, encrypted bucket, and add a DynamoDB table with a LockID hash key for state locking. This prevents concurrent edits when multiple team members run terraform apply.

Should I use count or for_each in Terraform resources?

Use for_each with a set or map when resources may be added or removed, since it keys resources by name and avoids destructive reordering. Use count only for simple positional lists where index stability is guaranteed.

How do I manage multiple environments in Terraform?

Create separate directories per environment, each with its own terraform.tfvars file and isolated state key in the S3 backend. This isolates the blast radius so a dev change cannot affect production state.

Can Terraform modules be tested automatically?

Yes, Terratest is a Go library that runs terraform init, apply, and destroy against example configurations and asserts on outputs. In CI, run terraform fmt, validate, and plan on pull requests before any apply.

Why does terraform apply fail with a state lock error?

A state lock error occurs when another apply is running or a previous run crashed without releasing the DynamoDB lock. Verify no active runs exist, then use terraform force-unlock with the lock ID to clear it.