mcpbeat

Terraform Iac

cosmicstack-labs/terraform-iac

State management, modules, workspaces, remote backends, and multi-environment strategies

473 tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
365
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/cosmicstack-labs/mercury-agent-skills --skill terraform-iac

The instruction itself

9 sections, as written by the author

Terraform / Infrastructure as Code

Manage infrastructure with Terraform.

Core Concepts

State Management

  • Store state remotely (S3, Terraform Cloud)
  • Enable state locking (DynamoDB)
  • Never edit state manually (use terraform state commands)
  • Isolate environments with workspaces or directories

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

  • Input validation (type constraints, validation blocks)
  • Outputs for all useful values
  • Versioned modules (Git tags, registry)
  • Documentation (README per module)
  • Test with Terratest

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

  • Workspaces: Simple, state separation only
  • Directory structure: Full isolation, can diff configs
  • Terragrunt: DRY config, repeatable structure
  • Always: Plan in CI, approve, then apply
  • No manual applies in production

How to use it

Copy the folder

Take cosmicstack-labs/terraform-iac from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.