Master Terraform HCL syntax, resources, providers, variables, and outputs with production-ready patterns
View on GitHubpluginagentmarketplace/custom-plugin-terraform
terraform-assistant
January 20, 2026
Select agents to install to:
npx add-skill https://github.com/pluginagentmarketplace/custom-plugin-terraform/blob/main/skills/terraform-fundamentals/SKILL.md -a claude-code --skill terraform-fundamentalsInstallation paths:
.claude/skills/terraform-fundamentals/# Terraform Fundamentals Skill
Master HashiCorp Configuration Language (HCL) and core Terraform concepts for building production infrastructure.
## Quick Reference
```hcl
# Block Types Overview
terraform {} # Settings & provider requirements
provider "x" {} # Provider configuration
resource "x" {} # Infrastructure objects
data "x" {} # Read external data
variable "x" {} # Input parameters
output "x" {} # Export values
locals {} # Computed values
module "x" {} # Reusable components
```
## Core Concepts
### 1. Provider Configuration
```hcl
terraform {
required_version = ">= 1.5.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = var.aws_region
default_tags {
tags = {
Environment = var.environment
ManagedBy = "Terraform"
}
}
}
```
### 2. Resource Definitions
```hcl
resource "aws_instance" "web" {
ami = data.aws_ami.ubuntu.id
instance_type = var.instance_type
subnet_id = aws_subnet.main.id
tags = merge(local.common_tags, {
Name = "${var.project}-web"
})
lifecycle {
create_before_destroy = true
prevent_destroy = var.environment == "prod"
ignore_changes = [tags["LastModified"]]
}
}
```
### 3. Variables with Validation
```hcl
variable "environment" {
type = string
description = "Deployment environment"
validation {
condition = contains(["dev", "staging", "prod"], var.environment)
error_message = "Must be dev, staging, or prod."
}
}
variable "instance_config" {
type = object({
instance_type = string
volume_size = number
enable_monitoring = optional(bool, true)
})
default = {
instance_type = "t3.micro"
volume_size = 20
}
}
```
### 4. Outputs
```hcl
output "instance_id" {
description = "EC2 instance ID"
value = aws_instance.web.id
}
output "connection_info" {
description = "SSH connection det