본문으로 건너뛰기
cccskills
무료GitHub에 공개

terraform-review

PR review checklist for Terraform changes covering structure, state safety, security, naming, modules, variables, providers, and CI/CD. Use when reviewing Terraform PRs or doing pre-merge checks.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구AWSTerraformRedis
설치 방법 보기

포함된 파일(1)

  • SKILL.md6.0 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Terraform Review

Runs an 8-category review checklist on Terraform changes. Produces an Approved / Needs Changes / Blocked verdict.

When to Use

  • Reviewing a Terraform pull request
  • Pre-merge validation of infrastructure changes
  • Self-review before opening a PR
  • Auditing existing Terraform code

Process

1. Structure

  • Files follow standard layout: live/, modules/, envs/
  • One resource per file in modules
  • terraform.tf has backend + provider config
  • variables.tf, outputs.tf, locals.tf are separate files
  • No .terraform/ or *.tfstate* in the PR
# CORRECT structure
terraform/
  live/terraform.tf        # backend + provider
  live/variables.tf        # inputs
  live/locals.tf           # computed values
  live/outputs.tf          # exports
  modules/{service}/       # one resource per file
  envs/{env}/              # per-environment config

# WRONG — everything in one file
terraform/main.tf          # 500 lines of mixed resources

2. State Safety

  • No terraform state commands in automation
  • State stored in S3 with DynamoDB locking
  • prevent_destroy on critical resources (RDS, S3 with data)
  • No resources removed without terraform state rm plan documented
  • create_before_destroy on security groups and launch configs
  • Import blocks used for adopting existing resources (not terraform import CLI)
# CORRECT — protect critical resources
resource "aws_db_instance" "main" {
  lifecycle {
    prevent_destroy = true
  }
}

# CORRECT — zero-downtime SG updates
resource "aws_security_group" "app" {
  name_prefix = "${local.name_prefix}-app-"
  lifecycle {
    create_before_destroy = true
  }
}

3. Security

  • No secrets in .tf or .tfvars committed to git
  • Sensitive variables marked sensitive = true
  • S3 buckets block public access
  • RDS/Redis in private subnets only
  • Security groups follow least privilege (no 0.0.0.0/0 ingress on non-ALB)
  • Encryption enabled (S3 SSE, RDS encryption, Redis transit + at-rest)
  • IAM policies use least privilege, no * actions on * resources
# WRONG — overly permissive
resource "aws_security_group_rule" "bad" {
  cidr_blocks = ["0.0.0.0/0"]
  from_port   = 0
  to_port     = 65535
}

# CORRECT — scoped to specific source
resource "aws_security_group_rule" "good" {
  source_security_group_id = var.alb_security_group_id
  from_port                = 8080
  to_port                  = 8080
}

4. Naming

  • Resources use local.name_prefix (pattern: {project}-{service}-{env})
  • Consistent naming across all resources in the module
  • Tags include: Project, Service, Environment, ManagedBy
  • No hardcoded names or account IDs
# CORRECT
locals {
  name_prefix = "${var.project}-${var.service}-${var.env}"
}

# WRONG
resource "aws_s3_bucket" "assets" {
  bucket = "my-bucket-prod"  # hardcoded
}

5. Modules

  • No provider blocks inside modules
  • Module source uses version pinning (?ref=vX.Y.Z)
  • No circular module dependencies
  • Module outputs only expose what consumers need
  • Modules have versions.tf with required provider versions
# CORRECT — pinned version
module "rds" {
  source = "git::https://github.com/{project}/terraform-modules.git//rds?ref=v1.2.0"
}

# WRONG — no version pin
module "rds" {
  source = "git::https://github.com/{project}/terraform-modules.git//rds"
}

6. Variables

  • All variables have description and type
  • Sensitive variables marked sensitive = true
  • Validation blocks on critical inputs (CIDR, names, enums)
  • No unused variables
  • Defaults are sensible for dev, overridden per env
# CORRECT
variable "instance_class" {
  description = "RDS instance class"
  type        = string
  default     = "db.t3.micro"

  validation {
    condition     = can(regex("^db\\.", var.instance_class))
    error_message = "Must be a valid RDS instance class."
  }
}

# WRONG — no description, no type
variable "instance_class" {}

7. Providers

  • Provider versions pinned with ~> (pessimistic constraint)
  • required_version for Terraform itself
  • Provider config only in live/terraform.tf, never in modules
  • Default tags configured at provider level

8. CI/CD

  • terraform fmt -check runs in CI
  • terraform validate runs in CI
  • Plan output posted as PR comment
  • Apply only runs on merge to main
  • State locking prevents concurrent applies
  • Secrets injected via CI environment, not committed

Interaction Style

  • Reads all changed .tf files in the PR
  • Checks every category — does not skip sections
  • Flags blocking issues (security, state safety) separately from suggestions
  • Shows exact file and line for each finding

Rules

  • Blocking issues: secrets in code, no state locking, 0.0.0.0/0 ingress, missing encryption
  • Needs Changes: missing descriptions, no version pin, naming inconsistency
  • Suggestions: code style, optional validations, documentation

Output

Produces a structured review:

## Terraform Review: {PR title}

### Verdict: Approved | Needs Changes | Blocked

### Findings

#### Blocked (if any)
- [ ] **[Security]** Secrets found in terraform.tfvars — file:line

#### Needs Changes (if any)
- [ ] **[Naming]** Hardcoded bucket name in s3.tf:12
- [ ] **[Modules]** Missing version pin on RDS module

#### Suggestions (if any)
- **[Variables]** Consider adding validation on `instance_class`

### Checklist Summary
| Category  | Status |
|-----------|--------|
| Structure | Pass   |
| State     | Pass   |
| Security  | Fail   |
| Naming    | Warn   |
| Modules   | Warn   |
| Variables | Pass   |
| Providers | Pass   |
| CI/CD     | Pass   |

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Creates RPC-style endpoint following layered architecture (Controller → Manager → Repository). Use when creating new API endpoints or CRUD operations.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1092026년 6월 18일 업데이트

Write blog posts, guides, tutorials, and long-form content. Sounds like a real person, not AI. Use when the user wants polished written content.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1092026년 6월 18일 업데이트

Design RPC-style APIs with layered architecture (Controller → Manager → Repository). Use when creating new API endpoints, designing API contracts, or reviewing API patterns.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1092026년 6월 18일 업데이트

Run a structured brainstorm session for startup ideas. Takes a theme or problem and generates ideas with quick gut-checks. Use when the user wants to explore a space or generate new ideas.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1092026년 6월 18일 업데이트

Run real browser QA with Playwright. Use when testing a frontend feature, verifying UI before PR, smoke testing after deploy, or investigating reported visual bugs.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1092026년 6월 18일 업데이트

CI/CD pipeline patterns for GitHub Actions, PR automation, and deployment workflows. Use when setting up CI, fixing broken pipelines, automating PR checks, or configuring deployment.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

c0x12c/ai-toolkit1092026년 6월 18일 업데이트

c0x12c의 스킬 모두 보기

이 스킬의 문제 신고