Terraform Infrastructure
Comprehensive Terraform infrastructure-as-code skill covering providers, resources, modules, state management, and enterprise patterns for multi-cloud infrastructure
- Skill ID
- manutej/luxor-claude-marketplace/terraform-infrastructure
- Publisher
- manutej
- Repository
- luxor-claude-marketplace
- Installs
- 0
- Files
- 3
- Synced
- Sep 23, 2026
Open any RiverX project, open the Skills panel in the chat, and search for this identifier. The files are fetched from the source repository at install time.
manutej/luxor-claude-marketplace/terraform-infrastructureInstalls these files- EXAMPLES.md
- README.md
- SKILL.md
What this skill tells the agent
Terraform Infrastructure-as-Code
A comprehensive skill for building, managing, and scaling cloud infrastructure using Terraform. Master declarative infrastructure, multi-cloud deployments, state management, module composition, and enterprise-grade patterns for AWS, Azure, GCP, and other providers.
When to Use This Skill
Use this skill when:
- Provisioning cloud infrastructure across AWS, Azure, GCP, or multi-cloud environments
- Building reusable infrastructure modules for teams and organizations
- Managing infrastructure state across multiple environments (dev, staging, production)
- Implementing infrastructure as code (IaC) best practices and governance
- Migrating from manual infrastructure to automated, version-controlled deployments
- Creating repeatable, testable infrastructure configurations
- Orchestrating complex multi-tier application architectures
- Managing Kubernetes clusters, databases, networks, and compute resources
- Implementing disaster recovery and multi-region deployments
- Collaborating on infrastructure changes with teams using GitOps workflows
Core Concepts
Infrastructure as Code Philosophy
Terraform enables declarative infrastructure management:
- Declarative Configuration: Define desired state, Terraform handles execution
- Immutable Infrastructure: Replace rather than modify infrastructure
- Version Control: Track infrastructure changes like application code
- Plan Before Apply: Preview changes before execution
- Resource Graph: Automatic dependency resolution and parallel execution
- State Management: Track real-world resources and their configuration
Key Terraform Components
- Providers: Plugins for infrastructure platforms (AWS, Azure, GCP, Kubernetes, etc.)
- Resources: Infrastructure objects (VMs, networks, databases, storage)
- Data Sources: Query existing infrastructure or external data
- Variables: Parameterize configurations for reusability
- Outputs: Export values for consumption by other configurations
- Modules: Reusable, composable infrastructure components
- State: JSON file tracking managed infrastructure
- Workspaces: Manage multiple instances of infrastructure
Terraform Workflow
Write → Init → Plan → Apply → Destroy
↓ ↓ ↓ ↓ ↓
.tf Download Review Execute Remove
files providers changes changes resourcesTerraform Language (HCL)
Basic Syntax
HCL (HashiCorp Configuration Language) is declarative and human-readable:
# Block structure
block_type "block_label" "block_name" {
argument_name = argument_value
nested_block {
nested_argument = value
}
}
# Example: EC2 instance resource
resource "aws_instance" "web_server" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t3.micro"
tags = {
Name = "WebServer"
Environment = "production"
}
}Variables and Types
Terraform supports rich type system:
# String variable
variable "region" {
type = string
description = "AWS region for resources"
default = "us-east-1"
}
# Number variable
variable "instance_count" {
type = number
default = 3
}
# Boolean variable
variable "enable_monitoring" {
type = bool
default = true
}
# List variable
variable "availability_zones" {
type = list(string)
default = ["us-east-1a", "us-east-1b", "us-east-1c"]
}
# Map variable
variable "instance_tags" {
type = map(string)
default = {
Environment = "production"
Project = "web-app"
}
}
# Object variable
variable "database_config" {
type = object({
engine = string
engine_version = string
instance_class = string
allocated_storage = number
})
default = {
engine = "postgres"
engine_version = "13.7"
instance_class = "db.t3.micro"
allocated_storage = 20
}
}
# Set variable
variable "allowed_cidr_blocks" {
type = set(string)
default = ["10.0.0.0/8", "172.16.0.0/12"]
}
# Tuple variable
variable "server_config" {
type = tuple([string, number, bool])
default = ["t3.micro", 2, true]
}Variable Validation
Add custom validation rules:
variable "instance_type" {
type = string
description = "EC2 instance type"
validation {
condition = contains(["t3.micro", "t3.small", "t3.medium"], var.instance_type)
error_message = "Instance type must be t3.micro, t3.small, or t3.medium."
}
}
variable "environment" {
type = string
validation {
condition = can(regex("^(dev|staging|prod)$", var.environment))
error_message = "Environment must be dev, staging, or prod."
}
}
variable "cidr_block" {
type = string
validation {
condition = can(cidrhost(var.cidr_block, 0))
error_message = "Must be a valid IPv4 CIDR block."
}
}Locals and Expressions
Locals compute values once and reuse them:
locals {
# Simple local
environment = terraform.workspace
# Computed local
common_tags = {
Environment = local.environment
ManagedBy = "Terraform"
Project = var.project_name
}
# Conditional local
instance_count = var.environment == "prod" ? 5 : 2
# List manipulation
all_subnets = concat(var.public_subnets, var.private_subnets)
# Map merging
merged_tags = merge(
local.common_tags,
var.additional_tags
)
# String interpolation
bucket_name = "${var.project_name}-${local.environment}-data"
# For expression
subnet_ids = [for subnet in aws_subnet.private : subnet.id]
# For expression with filtering
prod_instances = [
for instance in aws_instance.app :
instance.id if instance.tags["Environment"] == "prod"
]
# Map transformation
instance_map = {
for idx, instance in aws_instance.app :
instance.tags["Name"] => instance.id
}
}Functions
Terraform provides built-in functions:
# String functions
upper("hello") # "HELLO"
lower("WORLD") # "world"
title("hello world") # "Hello World"
trim(" spaces ") # "spaces"
trimprefix("prefix-value", "prefix-") # "value"
format("Server %03d", 1) # "Server 001"
join("-", ["a", "b", "c"]) # "a-b-c"
split("-", "a-b-c") # ["a", "b", "c"]
substr("hello", 0, 3) # "hel"
replace("hello", "l", "r") # "herro"
# Numeric functions
max(5, 12, 9) # 12
min(5, 12, 9) # 5
ceil(5.1) # 6
floor(5.9) # 5
parseint("100", 10) # 100
# Collection functions
length([1, 2, 3]) # 3
element(["a", "b", "c"], 1) # "b"
concat([1, 2], [3, 4]) # [1, 2, 3, 4]
contains(["a", "b"], "a") # true
distinct([1, 2, 2, 3]) # [1, 2, 3]
flatten([[1, 2], [3, 4]]) # [1, 2, 3, 4]
keys({a = 1, b = 2}) # ["a", "b"]
values({a = 1, b = 2}) # [1, 2]
lookup({a = 1, b = 2}, "a", 0) # 1
merge({a = 1}, {b = 2}) # {a = 1, b = 2}
reverse([1, 2, 3]) # [3, 2, 1]
slice([1, 2, 3, 4], 1, 3) # [2, 3]
sort(["c", "a", "b"]) # ["a", "b", "c"]
# Encoding functions
base64encode("hello") # "aGVsbG8="
base64decode("aGVsbG8=") # "hello"
jsonencode({key = "value"}) # "{\"key\":\"value\"}"
jsondecode("{\"key\":\"value\"}") # {key = "value"}
yamlencode({key = "value"}) # "key: value\n"
yamldecode("key: value") # {key = "value"}
# Filesystem functions
file("path/to/file.txt") # Read file content
templatefile("template.tpl", { # Render template
var1 = "value1"
})
# Date/time functions
timestamp() # "2024-01-15T12:30:45Z"
formatdate("DD MMM YYYY", timestamp()) # "15 Jan 2024"
# Network functions
cidrhost("10.0.0.0/24", 5) # "10.0.0.5"
cidrnetmask("10.0.0.0/24") # "255.255.255.0"
cidrsubnet("10.0.0.0/16", 8, 2) # "10.0.2.0/24"
More from manutej
Use this skill in a project
Open any RiverX project, search the Skills panel for manutej/luxor-claude-marketplace/terraform-infrastructure, and install it in one click.
