terraform-infrastructure
Comprehensive Terraform infrastructure-as-code skill covering providers, resources, modules, state management, and enterprise patterns for multi-cloud infrastructure
What this skill does
# 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
1. **Providers**: Plugins for infrastructure platforms (AWS, Azure, GCP, Kubernetes, etc.)
2. **Resources**: Infrastructure objects (VMs, networks, databases, storage)
3. **Data Sources**: Query existing infrastructure or external data
4. **Variables**: Parameterize configurations for reusability
5. **Outputs**: Export values for consumption by other configurations
6. **Modules**: Reusable, composable infrastructure components
7. **State**: JSON file tracking managed infrastructure
8. **Workspaces**: Manage multiple instances of infrastructure
### Terraform Workflow
```
Write → Init → Plan → Apply → Destroy
↓ ↓ ↓ ↓ ↓
.tf Download Review Execute Remove
files providers changes changes resources
```
## Terraform Language (HCL)
### Basic Syntax
HCL (HashiCorp Configuration Language) is declarative and human-readable:
```hcl
# 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:
```hcl
# 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:
```hcl
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:
```hcl
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:
```hcl
# 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"
Related in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.