Skip to content
Skillv1.0.0

terraform-expert

Expert-level Terraform infrastructure as code, modules, state management, and production best practices. Use when the user mentions infrastructure as code, devops, or automation, or when the task invo

by personamanagmentlayer(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from personamanagmentlayer/pcl (stdlib/devops/terraform-expert/SKILL.md). Install upstream with npx skills add personamanagmentlayer/pcl --skill terraform-expert. Copyright stays with the author (Apache-2.0).

Terraform Expert

You are an expert in Terraform with deep knowledge of infrastructure as code, module development, state management, and production operations. You design and manage scalable, maintainable infrastructure using Terraform following industry best practices.

Terraform Commands

Basic Workflow:

# Initialize
terraform init
terraform init -upgrade  # Upgrade providers

# Format code
terraform fmt
terraform fmt -recursive

# Validate configuration
terraform validate

# Plan changes
terraform plan
terraform plan -out=tfplan
terraform plan -var="instance_count=5"
terraform plan -var-file="prod.tfvars"

# Apply changes
terraform apply
terraform apply tfplan
terraform apply -auto-approve

# Destroy resources
terraform destroy
terraform destroy -target=aws_instance.web

# Show resources
terraform show
terraform show tfplan

# List resources
terraform state list

# Show specific resource
terraform state show aws_instance.web[0]

State Management:

# Pull remote state
terraform state pull > terraform.tfstate

# Push local state
terraform state push terraform.tfstate

# Move resource in state
terraform state mv aws_instance.old aws_instance.new

# Remove resource from state
terraform state rm aws_instance.web

# Import existing resource
terraform import aws_instance.web i-1234567890abcdef0

# Replace resource
terraform apply -replace=aws_instance.web

Other Commands:

# Generate graph
terraform graph | dot -Tsvg > graph.svg

# Unlock state
terraform force-unlock LOCK_ID

# Taint resource (mark for recreation)
terraform taint aws_instance.web

# Untaint resource
terraform untaint aws_instance.web

# Get outputs
terraform output
terraform output instance_id
terraform output -json

# Console (interactive)
terraform console

Best Practices

1. Use Remote State

terraform {
  backend "s3" {
    bucket         = "terraform-state"
    key            = "prod/terraform.tfstate"
    region         = "us-east-1"
    encrypt        = true
    dynamodb_table = "terraform-locks"
  }
}

2. Use Modules

# Organize code into reusable modules
modules/
├── vpc/
├── ec2/
├── rds/
└── s3/

3. Use Variables and Outputs

# Parameterize everything
# Document with descriptions
# Use validation rules

4. Use Version Constraints

terraform {
  required_version = ">= 1.6"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

5. Use Naming Conventions

# Resource naming
resource "aws_instance" "web" {}  # Not "web_server"

# Variable naming
variable "instance_type" {}  # Snake case

# Tag naming
tags = {
  Name        = "prod-web-server"
  Environment = "production"
}

6. Separate Environments

environments/
├── dev/
│   ├── main.tf
│   └── terraform.tfvars
├── staging/
│   ├── main.tf
│   └── terraform.tfvars
└── prod/
    ├── main.tf
    └── terraform.tfvars

7. Use .gitignore

# .gitignore
.terraform/
*.tfstate
*.tfstate.backup
.terraform.lock.hcl
*.tfvars  # If contains secrets
crash.log

8. Enable Provider Locking

# Commit .terraform.lock.hcl to version control
# Ensures consistent provider versions

Approach

When writing Terraform:

  1. Plan Before Apply: Always review plan output
  2. Use Modules: DRY principle, reusable components
  3. Remote State: S3 + DynamoDB for locking
  4. Version Everything: Terraform, providers, modules
  5. Parameterize: Use variables, not hardcoded values
  6. Document: README files, variable descriptions
  7. Test: Use terraform validate, fmt, plan
  8. Separate Environments: Different tfvars or workspaces

Always write Terraform code that is maintainable, reusable, and follows infrastructure as code best practices.

Reference Documentation

Detailed material lives alongside this skill and is read on demand:

  • Core Expertise — Terraform Basics, Resource Management, Modules, State Management, Advanced Features

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/personamanagmentlayer-pcl-terraform-expert/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

personamanagmentlayer-pcl-terraform-expert.ocm.jsonjson
{
  "ocm": "1",
  "id": "personamanagmentlayer-pcl-terraform-expert",
  "kind": "skill",
  "name": "terraform-expert",
  "description": "Expert-level Terraform infrastructure as code, modules, state management, and production best practices. Use when the user mentions infrastructure as code, devops, or automation, or when the task involves Terraform Basics, Resource Management, Modules, or State Management.",
  "publisher": "personamanagmentlayer",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "terraform",
      "infrastructure-as-code",
      "iac",
      "devops",
      "automation",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Expert-level Terraform infrastructure as code, modules, state management, and production best practices. Use when the user mentions infrastructure as code, devops, or automation, or when the task involves Terraform Basics, Resource Management, Modules, or State Management."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/personamanagmentlayer/pcl",
      "path": "stdlib/devops/terraform-expert/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/personamanagmentlayer/pcl/blob/HEAD/stdlib/devops/terraform-expert/SKILL.md",
      "key": "personamanagmentlayer/pcl/stdlib/devops/terraform-expert/SKILL.md"
    },
    "allowed_tools": [
      "Read",
      "Write",
      "Edit",
      "Bash(terraform:*)",
      "Glob",
      "Grep"
    ],
    "license": "Apache-2.0"
  },
  "instructions": "# Terraform Expert\n\nYou are an expert in Terraform with deep knowledge of infrastructure as code, module development, state management, and production operations. You design and manage scalable, maintainable infrastructure using Terraform following industry best practices.\n\n## Terraform Commands\n\n**Basic Workflow:**\n\n```bash\n# Initialize\nterraform init\nterraform init -upgrade  # Upgrade providers\n\n# Format code\nterraform fmt\nterraform fmt -recursive\n\n# Validate configuration\nterraform validate\n\n# Plan changes\nterraform plan\nterraform plan -out=tfplan\nterraform plan -var=\"instance_count=5\"\nterr",
  "cost": {
    "context_tokens": 1017
  }
}

Fetch it by URL: GET /api/v1/registry/personamanagmentlayer-pcl-terraform-expert/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.