Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问许可证需确认审计提醒

terraformTerraform 基础设施

Agent Skill

用于辅助云资源、部署、容器、基础设施和运维自动化任务。它适合让 Agent 检查配置、整理部署步骤、分析资源状态、生成排障思路或辅助云服务接入。使用时需要明确目标环境、账号权限、区域和资源组,区分本地测试与生产操作;涉及删除资源、重启服务、修改网络或权限配置时,应先确认影响范围。

总安装

264

周安装

11

GitHub Stars

2

下载量

88
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:terraform(Terraform 基础设施)
来源仓库:https://github.com/benjaminwestern/google-engineer-skills
仓库路径:skills/terraform
安装命令:
npx skills add https://github.com/benjaminwestern/google-engineer-skills --skill terraform
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/benjaminwestern/google-engineer-skills --skill terraform

简介

提供 Terraform 基础设施即代码的最佳实践指导。

  • 覆盖模块设计、状态管理、CI/CD 集成与生产级部署模式。
  • 强调版本控制、后端配置与垂直分域文件组织原则。
  • 使用前需确认云账号权限与环境隔离策略,避免误删关键资源。
  • terraform 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Terraform Skill

Comprehensive Terraform guidance covering modules, testing, CI/CD, and production patterns. Combines best practices from terraform-best-practices.com and Cloud Foundation Fabric.


The Seven Mantras

These principles guide all Terraform work:

  1. Always Have versions.tf — Every root module must define providers, versions, and configuration. Never leave provider config implicit.
  2. Always Have backend.tf — Even if empty initially, you'll need remote state (GCS for GCP).
  3. Always Have locals.tf — Centralize all local values, don't scatter them across files.
  4. Vertical Files by Domain — Organize by workload (webserver.tf, salesforce-etl.tf), not by resource type (iam.tf, compute.tf).
  5. Variables with Sane Defaults — Provide sensible defaults and example tfvars files.
  6. YAML Factories for Heavy Reuse — Enable non-Terraform users via YAML configs + factory patterns.
  7. Maximize Autonomy — App repos own their resources, foundations repos own shared infrastructure. Avoid cross-repo dependencies.

Core Principles

1. Required Files

Every Terraform root module must have:

FilePurpose
versions.tfProvider versions and configuration
backend.tfRemote state (even if empty initially)
locals.tfCentralized local values
variables.tfInput variables (when needed)

2. Vertical File Organization

Organize by domain/workload, not by resource type:

# GOOD - Files by domain:
├── networking.tf      # VPC, subnets, routes, NAT
├── webserver.tf       # MIG, template, LB, service account
├── salesforce-etl.tf  # SA, secrets, Cloud Function, BigQuery
└── database.tf        # Cloud SQL, IAM, backups

# BAD - Files by resource type:
├── iam.tf            # All IAM mixed together
├── compute.tf        # All compute mixed together
└── storage.tf        # All storage mixed together

3. Naming Conventions

TypePatternExample
ResourcesDescriptive, contextualweb_server, application_logs
SingletonsUse thisgoogle_compute_network.this
VariablesContext-specificvpc_cidr_block, database_instance_class
Outputs{name}_{type}_{attribute}firewall_rule_id, subnet_ids

4. Module Boundaries

TypeScopeExample
Resource ModuleSingle logical groupVPC + subnets
Infrastructure ModuleCollection of resourcesComplete networking stack
CompositionEnvironment-specificProduction environment
RepositoryOwns its resourcesApp repo = app resources only

Quick Decision Reference

Count vs For_Each

Do resources need meaningful identifiers?
│
├─ YES → for_each (with set or map)
│
└─ NO → Can items change position?
    ├─ YES → for_each (prevents cascade)
    └─ NO → count (simpler)

See code-patterns.md for migration patterns and detailed examples.

Testing Approach

What do you need to test?
│
├─ Syntax/format? → terraform validate + fmt
├─ Security? → trivy + checkov
├─ Simple logic (1.6+)? → Native tests
└─ Complex integration? → Terratest

See testing-frameworks.md for implementation details.

Authentication (GCP)

Always use OIDC. Never use service account keys.

MethodSecurityUse Case
OIDC✅ No long-lived credentialsCI/CD (GitHub Actions)
ADC✅ User credentialsLocal development
Impersonation✅ Service account delegationAutomation
Keys❌ Long-lived riskNever use

See security-compliance.md for OIDC setup and security patterns.


Modern Features (Quick Reference)

FeatureVersionWhen to Use
try()0.13+Safe fallbacks (always use)
optional()1.3+Optional object attributes
moved blocks1.1+Refactor without recreation
Native tests1.6+Unit testing in HCL
Mock providers1.7+Cost-free testing
Write-only args1.11+Secrets (never in state)

Essential Commands

# Static analysis (always free)
terraform fmt -recursive -check
terraform validate
tflint
trivy config .
checkov -d .

# Testing (1.6+)
terraform test

# Plan and apply
terraform plan -out=tfplan
terraform apply -auto-approve tfplan

# State management
terraform state list
terraform show

See quick-reference.md for full cheat sheet.


Security Checklist

  • Authentication: Using OIDC (not keys)
  • Secrets: In Secret Manager (not state/variables)
  • Network: Custom VPC (not default)
  • Firewall: Least privilege (not 0.0.0.0/0)
  • State: Encrypted, versioned, restricted access
  • Scanning: Trivy/Checkov in CI/CD

See security-compliance.md for detailed patterns.


Module Checklist

  • versions.tf with provider constraints
  • backend.tf for remote state
  • variables.tf with descriptions and validation
  • outputs.tf with descriptions
  • examples/ directory (simple and complete)
  • Tests (native 1.6+ or Terratest)
  • Pre-commit hooks configured
  • Documentation in README.md

See module-patterns.md for details.


CI/CD Essentials

Standard Pipeline

validate → plan → apply

Key Decisions

DecisionRecommendation
AuthenticationOIDC (never keys)
Apply triggerPush for dev/staging, approval for prod
WorkspacesSeparate files per environment
Security scanTrivy + Checkov in CI

See ci-cd-workflows.md for templates.


Reference Documentation

code-patterns.md

When to use: Writing or refactoring Terraform code

Covers:

  • Count vs for_each decision guide and migration patterns
  • Block ordering rules (resources, variables)
  • Modern features decision guide (try, optional, moved, write-only)
  • Version constraints and update strategy
  • Secrets management patterns
  • Refactoring from legacy (0.12/0.13) to modern syntax

quick-reference.md

When to use: Need quick lookup or troubleshooting

Covers:

  • Command cheat sheet (format, validate, test, plan)
  • Decision flowcharts (testing, module workflow, refactoring)
  • Version-specific guidance (1.0-1.5, 1.6+, 1.7+)
  • Troubleshooting common issues
  • Version constraint syntax reference

module-patterns.md

When to use: Creating or restructuring modules

Covers:

  • Module type decision tree (Resource → Infrastructure → Composition)
  • Architecture decisions (scope size, module connections)
  • File organization standards
  • Parameterization vs hardcoding
  • Root module vs reusable module boundaries
  • Naming decisions (variables, outputs)
  • Anti-patterns to avoid (god modules, environment sprawl)

testing-frameworks.md

When to use: Setting up or choosing testing approach

Covers:

  • Testing decision flowchart
  • Native tests vs Terratest comparison
  • Critical plan vs apply decision
  • Working with set-type blocks
  • Mocking decisions
  • Terratest patterns and cost management
  • Testing checklist

ci-cd-workflows.md

When to use: Setting up CI/CD pipelines

Covers:

  • Standard validate → plan → apply pipeline
  • OIDC authentication patterns
  • Apply strategy options (push, approval, comment-triggered)
  • Environment organization (separate vs reusable workflows)
  • Essential security checks in CI
  • Atlantis integration decision guide

security-compliance.md

When to use: Security review or compliance setup

Covers:

  • OIDC vs service account key decision
  • Secrets management (what's safe vs unsafe)
  • Network architecture decisions
  • Firewall rule best practices
  • State security requirements
  • Compliance testing tools (trivy, checkov, terraform-compliance, OPA)

factory-patterns.md

When to use: Building scalable, self-service infrastructure

Covers:

  • When to use factory vs traditional modules
  • Configuration format decisions (YAML vs JSON)
  • Discovery methods (single file vs auto-discovery)
  • Default strategy patterns
  • Factory patterns by use case (Project, Subnet, Service Account)
  • Conditional resource creation
  • Lifecycle hooks
  • When NOT to use factory pattern

Based on:

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.54%
按下载量换算32

Claude

30.44%
按下载量换算27

Cursor

18.09%
按下载量换算16

Gemini CLI

9.4%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills