
Terraform Engineer
Refactor and extend Terraform for solo-owned cloud infra using modules, locals, and data sources instead of copy-paste resources.
Install
npx skills add https://github.com/jeffallan/claude-skills --skill terraform-engineerWhat is this skill?
- Module-based VPC and repeated environment patterns instead of duplicated resource blocks
- Locals for common_tags, name_prefix, environment-specific CIDR, and AZ slicing
- Data sources for AMI and AZ lookups instead of hardcoded cloud IDs
- Before/after HCL examples labeled Bad vs Good for teaching refactors
- Aligns with Terraform best-practices framing for reusable indie stacks
Adoption & trust: 3.1k installs on skills.sh; 9.7k GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Journey fit
Terraform hygiene is canonically shelved under Operate infra because it governs how production and staging environments stay repeatable after the first deploy. Content targets VPC modules, tagging locals, dynamic AMI lookups, and DRY HCL—core infrastructure-as-code work rather than app feature coding.
Common Questions / FAQ
Is Terraform Engineer safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Terraform Engineer
# Terraform Best Practices ## DRY Principles **Use Modules for Reusability** ```hcl # Bad - Repeated code resource "aws_vpc" "app1" { cidr_block = "10.0.0.0/16" enable_dns_hostnames = true tags = { Name = "app1-vpc", Environment = "prod" } } resource "aws_vpc" "app2" { cidr_block = "10.1.0.0/16" enable_dns_hostnames = true tags = { Name = "app2-vpc", Environment = "prod" } } # Good - Use module module "vpc_app1" { source = "./modules/vpc" name = "app1" cidr_block = "10.0.0.0/16" environment = "prod" } module "vpc_app2" { source = "./modules/vpc" name = "app2" cidr_block = "10.1.0.0/16" environment = "prod" } ``` **Use Locals for Repeated Values** ```hcl locals { common_tags = { Environment = var.environment ManagedBy = "Terraform" Project = var.project_name CostCenter = var.cost_center } name_prefix = "${var.project_name}-${var.environment}" # Computed locals vpc_cidr = var.environment == "production" ? "10.0.0.0/16" : "10.1.0.0/16" # Complex data structures availability_zones = slice(data.aws_availability_zones.available.names, 0, var.az_count) } resource "aws_vpc" "main" { cidr_block = local.vpc_cidr tags = merge(local.common_tags, { Name = "${local.name_prefix}-vpc" }) } ``` **Use Data Sources Instead of Hardcoding** ```hcl # Bad - Hardcoded AMI resource "aws_instance" "web" { ami = "ami-0c55b159cbfafe1f0" instance_type = "t3.micro" } # Good - Dynamic AMI lookup data "aws_ami" "amazon_linux_2" { most_recent = true owners = ["amazon"] filter { name = "name" values = ["amzn2-ami-hvm-*-x86_64-gp2"] } filter { name = "virtualization-type" values = ["hvm"] } } resource "aws_instance" "web" { ami = data.aws_ami.amazon_linux_2.id instance_type = "t3.micro" } ``` **Use for_each for Multiple Similar Resources** ```hcl # Bad - Duplicated resources resource "aws_subnet" "private_1" { vpc_id = aws_vpc.main.id cidr_block = "10.0.1.0/24" availability_zone = "us-east-1a" } resource "aws_subnet" "private_2" { vpc_id = aws_vpc.main.id cidr_block = "10.0.2.0/24" availability_zone = "us-east-1b" } # Good - Use for_each variable "private_subnets" { type = map(object({ cidr_block = string az = string })) default = { subnet1 = { cidr_block = "10.0.1.0/24", az = "us-east-1a" } subnet2 = { cidr_block = "10.0.2.0/24", az = "us-east-1b" } } } resource "aws_subnet" "private" { for_each = var.private_subnets vpc_id = aws_vpc.main.id cidr_block = each.value.cidr_block availability_zone = each.value.az tags = { Name = "${var.name}-private-${each.key}" } } ``` ## Naming Conventions **Resource Naming** ```hcl # Pattern: {resource_type}_{descriptive_name} # Good examples resource "aws_vpc" "main" {} resource "aws_subnet" "private" {} resource "aws_security_group" "web" {} resource "aws_instance" "app" {} # Avoid generic names resource "aws_vpc" "vpc" {} # Bad resource "aws_subnet" "subnet" {} # Bad resource "aws_vpc" "this" {} # Use in modules only ``` **AWS Resource Name Tags** ```hcl locals { # Pattern: {project}-{environment}-{resource}-{identifier} name_prefix = "${var.project_name}-${var.environment}" } resource "aws_vpc" "main" { cidr_block = var.cidr_block tags = merge(local.common_tags, { Name = "${local.name_prefix}-vpc" }) } resource "aws_subnet" "private" { for_each = var.private_subnets vpc_id = aws_vpc.main.id cidr_block = each.value.cidr_block tags = merge(local.common_tags, { Name = "${local.name_prefix}-private-${each.key}" Type = "private" }) } resource "aws_security_group" "web" { name = "${local.name_prefix}-web-sg" vpc_id = aws_vpc.main.id tags = merge(local.common_tags, { Name = "${local.name_prefix}-web-sg" }) } ``` **Variable Naming** ```hcl # Use snake_case for all na