MCP HubMCP Hub
SKILL·ECC3F3

provision-infrastructure-terraform

pjt222
업데이트됨 1 month ago
10 조회
26
3
26
GitHub에서 보기
기타general

정보

이 스킬은 Terraform을 사용하여 클라우드 인프라를 프로비저닝하고 관리하며, HACL 모듈, 원격 상태 백엔드, 플랜/적용 워크플로우를 통해 인프라를 코드로 구현합니다. 변수 관리, 출력 값, 상태 잠금을 통해 팀 협업을 가능하게 합니다. 새로운 클라우드 리소스 설정, ClickOps/CloudFormation에서 IaC로 마이그레이션, 다중 환경 인프라 관리, 재사용 가능한 모듈로 표준 적용 등에 사용하세요.

빠른 설치

Claude Code

추천
기본
npx skills add pjt222/agent-almanac -a claude-code
플러그인 명령대체
/plugin add https://github.com/pjt222/agent-almanac
Git 클론대체
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/provision-infrastructure-terraform

Claude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요

문서

以 Terraform 配基礎設施

以 Terraform 實作基礎為碼,配、版、管 AWS、Azure、GCP、他供之雲資源。

用時

  • 配新雲基設(VPC、計算、存、資料庫)
  • 自 ClickOps 或 CloudFormation 遷至宣告式 IaC
  • 管多環基設(dev、staging、prod)
  • 跨隊實可復現之基設模式
  • 與應用碼並版基設變
  • 透可重用模強基設標

  • 必要:Terraform CLI 已裝(terraform --version)
  • 必要:雲供之憑(AWS、Azure、GCP 服戶)
  • 必要:遠程狀態後端配(S3、Azure Storage、Terraform Cloud)
  • 可選:欲入或遷之既基設
  • 可選:Terraform Cloud/Enterprise 為隊協
  • 可選:為驗與格之 pre-commit 鉤

完整配文與模板見 Extended Examples

第一步:始 Terraform 項結構

立有序之目構,附後端配與供設。

# Create project structure
mkdir -p terraform/{modules,environments/{dev,staging,prod}}
cd terraform

# Create backend configuration
cat > backend.tf <<'EOF'
terraform {
  required_version = ">= 1.6"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }

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

    # Workspace-specific state files
    workspace_key_prefix = "env"
  }
}

provider "aws" {
  region = var.aws_region

  default_tags {
    tags = {
      ManagedBy   = "Terraform"
      Environment = terraform.workspace
      Project     = var.project_name
    }
  }
}
EOF

# Create variables file
cat > variables.tf <<'EOF'
variable "aws_region" {
  description = "AWS region for resources"
  type        = string
  default     = "us-east-1"
}

variable "project_name" {
  description = "Project name for resource naming and tagging"
  type        = string
  validation {
    condition     = length(var.project_name) > 0 && length(var.project_name) <= 32
    error_message = "Project name must be 1-32 characters"
  }
}

variable "environment" {
  description = "Environment name (dev, staging, prod)"
  type        = string
  validation {
    condition     = contains(["dev", "staging", "prod"], var.environment)
    error_message = "Environment must be dev, staging, or prod"
  }
}
EOF

# Initialize Terraform
terraform init

得:Terraform 順始、下供插件、配遠後端。.terraform/ 目立含供二進制。狀態後端連已驗。

敗則:若後端始敗,驗 S3 桶在且 IAM 權許 s3:GetObjects3:PutObjectdynamodb:GetItemdynamodb:PutItem。供下敗者,察網與企代理設。行 terraform init -upgrade 以更供。

第二步:立可重用之基設模

建可組之 VPC、計算、資料基設模,附入驗。

# modules/vpc/main.tf
variable "vpc_cidr" {
  description = "CIDR block for VPC"
  type        = string
  default     = "10.0.0.0/16"
}

variable "availability_zones" {
  description = "List of AZs to use"
  type        = list(string)
}

variable "project_name" {
  description = "Project name for resource naming"
  type        = string
}

variable "environment" {
  description = "Environment name"
  type        = string
}

locals {
  common_tags = {
    Project     = var.project_name
    Environment = var.environment
    Module      = "vpc"
  }
}

resource "aws_vpc" "main" {
  cidr_block           = var.vpc_cidr
  enable_dns_hostnames = true
  enable_dns_support   = true

  tags = merge(local.common_tags, {
    Name = "${var.project_name}-${var.environment}-vpc"
  })
}

resource "aws_subnet" "public" {
  count             = length(var.availability_zones)
  vpc_id            = aws_vpc.main.id
  cidr_block        = cidrsubnet(var.vpc_cidr, 8, count.index)
  availability_zone = var.availability_zones[count.index]

  map_public_ip_on_launch = true

  tags = merge(local.common_tags, {
    Name = "${var.project_name}-${var.environment}-public-${var.availability_zones[count.index]}"
    Type = "public"
  })
}

resource "aws_subnet" "private" {
  count             = length(var.availability_zones)
  vpc_id            = aws_vpc.main.id
  cidr_block        = cidrsubnet(var.vpc_cidr, 8, count.index + 100)
  availability_zone = var.availability_zones[count.index]

  tags = merge(local.common_tags, {
    Name = "${var.project_name}-${var.environment}-private-${var.availability_zones[count.index]}"
    Type = "private"
  })
}

resource "aws_internet_gateway" "main" {
  vpc_id = aws_vpc.main.id

  tags = merge(local.common_tags, {
    Name = "${var.project_name}-${var.environment}-igw"
  })
}

resource "aws_eip" "nat" {
  count  = length(var.availability_zones)
  domain = "vpc"

  tags = merge(local.common_tags, {
    Name = "${var.project_name}-${var.environment}-nat-eip-${var.availability_zones[count.index]}"
  })

  depends_on = [aws_internet_gateway.main]
}

resource "aws_nat_gateway" "main" {
  count         = length(var.availability_zones)
  allocation_id = aws_eip.nat[count.index].id
  subnet_id     = aws_subnet.public[count.index].id

  tags = merge(local.common_tags, {
    Name = "${var.project_name}-${var.environment}-nat-${var.availability_zones[count.index]}"
  })

  depends_on = [aws_internet_gateway.main]
}

# modules/vpc/outputs.tf
output "vpc_id" {
  description = "VPC ID"
  value       = aws_vpc.main.id
}

output "public_subnet_ids" {
  description = "List of public subnet IDs"
  value       = aws_subnet.public[*].id
}

output "private_subnet_ids" {
  description = "List of private subnet IDs"
  value       = aws_subnet.private[*].id
}

output "nat_gateway_ips" {
  description = "List of NAT Gateway public IPs"
  value       = aws_eip.nat[*].public_ip
}

得:模立 VPC 含跨多 AZ 之公/私子網、互聯網閘道、NAT 閘道附 EIP。輸出值露資源 ID 供下游模。

敗則:CIDR 重誤者,調 cidrsubnet() 算或驗 VPC CIDR 不衝既網。依誤者,驗 depends_on 塊確正資源立序。用 terraform graph | dot -Tpng > graph.png 視覺化依。

第三步:實環特定配

立環工作區附變覆與資料源。

# environments/prod/main.tf
terraform {
  required_version = ">= 1.6"
}

# Import shared backend and provider config
# ... (see EXAMPLES.md for complete configuration)

得:環特定配立 prod 大小之基設,含 3 AZ、較大實例型、prod 安全設。資料源解最新 AMI。模板文以環變渲。

敗則:工作區誤者,以 terraform workspace new prod 立。資料源敗者,驗 AWS 憑有 ec2:DescribeImages 權。模板渲誤者,驗變型合模板期。

第四步:執 plan 與 apply 流

行 Terraform plan、察變、附核工流 apply。

# Format code
terraform fmt -recursive

# Validate configuration
terraform validate

# ... (see EXAMPLES.md for complete configuration)

為自動 CI/CD 整合:

# .github/workflows/terraform.yml
name: Terraform

on:
  pull_request:
    paths:
# ... (see EXAMPLES.md for complete configuration)

得:plan 示資源加/變/刪。無漂。apply 立/更資源無誤。輸出含期值。CI 流於 PR 評 plan、合主分支時自 apply。

敗則:plan 敗者,行 terraform validate 捕語法誤。狀鎖誤者,以 aws dynamodb get-item --table-name terraform-lock --key '{"LockID":{"S":"terraform-state-bucket/key"}}' 識鎖持,陳則強解。apply 敗者,察 CloudWatch 記為供特誤。用 terraform show 察當狀。

第五步:管狀態並實漂測

配狀鎖、備、自漂測。

# Create DynamoDB table for state locking
cat > state-backend.tf <<'EOF'
resource "aws_dynamodb_table" "terraform_lock" {
  name           = "terraform-lock"
  billing_mode   = "PAY_PER_REQUEST"
  hash_key       = "LockID"
# ... (see EXAMPLES.md for complete configuration)

為自漂測:

# Create drift detection script
cat > scripts/detect-drift.sh <<'EOF'
#!/bin/bash
set -euo pipefail

cd terraform
# ... (see EXAMPLES.md for complete configuration)

得:狀後端配有版與加。漂測識帶外變。狀操(list、show、mv、import)行無誤。自漂察排定行並發警。

敗則:狀鎖超時者,驗 DynamoDB 表在且鍵架構正。版誤者,以 aws s3api get-bucket-versioning --bucket bucket-name 察 S3 桶版狀。入誤者,驗資源在且 Terraform 配合實資源屬性。

第六步:實模試與文

加 Terratest 自試並生文。

// test/vpc_test.go
package test

import (
    "testing"

# ... (see EXAMPLES.md for complete configuration)

生文:

# Install terraform-docs
go install github.com/terraform-docs/terraform-docs@latest

# Generate module documentation
terraform-docs markdown table modules/vpc > modules/vpc/README.md

# ... (see EXAMPLES.md for complete configuration)

得:Terratest 驗模立期資源附正配。文自變述與輸出定生。pre-commit 鉤於提交前強格與驗。

敗則:Terratest 敗者,察 AWS 憑與配額。長行試者,以 t.Parallel() 實並行。文生誤者,驗諸變有 description 屬性。pre-commit 敗者,手行 terraform fmt 並修驗誤。

  • 後端配有加、版、狀鎖
  • 諸模有入驗與輸出值
  • 工作區隔環特狀
  • apply 後 terraform plan 示無意外變
  • 漂測自行並對變發警
  • 模以 Terratest 或類框試
  • 文自生並維最新
  • 祕由 AWS Secrets Manager 管,非硬編
  • 費估已整合(Infracost 或類)
  • 各環別狀致爆破範減

  • 硬編值:避硬編 AMI ID、AZ、戶特值。用資料源與變。

  • 缺生命週期塊:資源意外重立。加 lifecycle { create_before_destroy = true } 防更時停機。

  • 無狀鎖:並行 apply 壞狀。常以 DynamoDB 表為 S3 後端鎖。

  • 過寬 IAM:Terraform 服戶有全管權。實限於管資源之最少權策。

  • 無版限:供更破基設。以 version = "~> 5.0" 限固供版。

  • 狀中之祕:敏值以明文存於狀文。輸出用 sensitive = true,祕存於 AWS Secrets Manager,由資料源引。

  • 無備策:狀文失或壞而無復謀。啟 S3 版、實常狀備、試復程序。

  • 單塊配:單狀文管全基設。分為邏輯界(網、計算、資料)以減爆破範。

  • configure-git-repository — Terraform 碼之版控
  • build-ci-cd-pipeline — 以 GitHub Actions 自動化 Terraform 流
  • implement-gitops-workflow — ArgoCD/Flux 與 Terraform 整合
  • manage-kubernetes-secrets — Terraform 配之集群中之祕管
  • deploy-to-kubernetes — Terraform Kubernetes 供之用

GitHub 저장소

pjt222/agent-almanac
경로: i18n/wenyan/skills/provision-infrastructure-terraform
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams
FAQ

Frequently asked questions

What is the provision-infrastructure-terraform skill?

provision-infrastructure-terraform is a Claude Skill by pjt222. Skills package instructions and resources that Claude loads on demand, so Claude can perform provision-infrastructure-terraform-related tasks without extra prompting.

How do I install provision-infrastructure-terraform?

Use the install commands on this page: add provision-infrastructure-terraform to Claude Code as a plugin, or clone its repository into your skills directory, then restart Claude so it picks up the skill.

What category does provision-infrastructure-terraform belong to?

provision-infrastructure-terraform is in the Other category, tagged general.

Is provision-infrastructure-terraform free to use?

Yes. provision-infrastructure-terraform is listed on AIMCP and free to install. It runs inside Claude, so no separate service account is required to use the skill itself.

연관 스킬

llamaguard
기타

LlamaGuard는 폭력 및 혐오 발언 등 6가지 안전 범주에서 LLM 입력과 출력을 조정하기 위한 Meta의 70-80억 파라미터 모델입니다. 94-95% 정확도를 제공하며 vLLM, Hugging Face 또는 Amazon SageMaker를 사용해 배포할 수 있습니다. 이 기술을 사용하여 AI 애플리케이션에 콘텐츠 필터링 및 안전 가드레일을 손쉽게 통합하세요.

스킬 보기
cost-optimization
기타

이 Claude Skill은 리소스 적정화, 태깅 전략, 지출 분석을 통해 개발자들이 클라우드 비용을 최적화할 수 있도록 지원합니다. AWS, Azure, GCP에서 클라우드 비용을 절감하고 비용 거버넌스를 구현하기 위한 프레임워크를 제공합니다. 인프라 비용을 분석하거나, 리소스를 적정화하거나, 예산 제약을 충족해야 할 때 사용하세요.

스킬 보기
sports-betting-analyzer
기타

이 Claude Skill은 스프레드, 오버/언더, 프로프 베트를 포함한 스포츠 베팅 시장을 분석합니다. 역사적 추이와 상황별 통계를 검토하여 가치 베트를 발견하고, 교육적 목적으로 실행 가능한 권장 사항이 담긴 구조화된 마크다운 결과를 제공합니다. 개발자는 이 기능을 스포츠 베팅 분석 도구에 활용할 수 있으며, 단순히 엔터테인먼트/교육 목적으로만 설계되었음을 유의해야 합니다.

스킬 보기
quantizing-models-bitsandbytes
기타

이 스킬은 bitsandbytes를 사용하여 LLM을 8비트 또는 4비트 정밀도로 양자화하며, 최소한의 정확도 손실로 50-75%의 메모리 감소를 달성합니다. 제한된 GPU 메모리에서 더 큰 모델을 실행하거나 추론을 가속화하는 데 이상적이며, INT8, NF4, FP4와 같은 형식을 지원합니다. 이 스킬은 HuggingFace Transformers와 통합되어 QLoRA 학습 및 8비트 옵티마이저를 가능하게 합니다.

스킬 보기