Terraform iac

From cosmicstack-labs/mercury-agent-skills · View interactive version

Terraform iac is an AI agent skill from the GitHub repository cosmicstack-labs/mercury-agent-skills. State management, modules, workspaces, remote backends, and multi-environment strategies

How to use this skill

Skill file

Terraform / Infrastructure as Code

Manage infrastructure with Terraform.

Core Concepts

State Management

Structure

terraform/
├── modules/
│   ├── networking/
│   ├── compute/
│   └── database/
├── environments/
│   ├── dev/
│   │   ├── main.tf
│   │   ├── variables.tf
│   │   └── terraform.tfvars
│   ├── staging/
│   └── production/
└── backend.tf

Module Design

Module Interface

# modules/compute/main.tf
variable "instance_type" { type = string }
variable "subnet_id"     { type = string }

output "instance_id" { value = aws_instance.app.id }

Module Best Practices

Remote Backend

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

Multi-Environment Strategy

  1. Workspaces: Simple, state separation only
  2. Directory structure: Full isolation, can diff configs
  3. Terragrunt: DRY config, repeatable structure
  4. Always: Plan in CI, approve, then apply
  5. No manual applies in production
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.