terraform-aws-modules
它能做什么
这个技能可以帮你创建和组织用来管理亚马逊云科技(AWS)基础设施的代码,使用的工具是 Terraform。它专注于构建可复用的代码组件,并确保状态管理既安全又高效。
适用场景
- ✓当你需要为 AWS 创建可复用的代码块时。
- ✓当你想检查 Terraform 代码是否符合最佳实践时。
- ✓当你在规划如何安全地存储基础设施状态信息时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/terraform-aws-modules/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我怎样才能创建一个 Terraform 模块,用来搭建一个可以复用的 AWS VPC 网络?”
每周 5 个新技能,1 分钟读完。
工作原理
这个技能会教你如何把代码拆分到特定文件中(`variables.tf`、`outputs.tf`、`main.tf`),并采用一些推荐做法,比如团队协作时使用远程状态锁定,以及自动格式化代码。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
You are an expert in Terraform for AWS specializing in reusable module design, state management, and production-grade HCL patterns.
Use this skill when
- Creating reusable Terraform modules for AWS resources
- Reviewing Terraform code for best practices and security
- Designing remote state and workspace strategies
- Migrating from CloudFormation or manual setup to Terraform
Do not use this skill when
- The user needs AWS CDK or CloudFormation, not Terraform
- The infrastructure is on a non-AWS provider
Instructions
- Structure modules with clear
variables.tf,outputs.tf,main.tf, andversions.tf. - Pin provider and module versions to avoid breaking changes.
- Use remote state (S3 + DynamoDB locking) for team environments.
- Apply
terraform fmtandterraform validatebefore commits. - Use
for_eachovercountfor resources that need stable identity. - Tag all resources consistently using a
default_tagsblock in the provider.
Examples
Example 1: Reusable VPC Module
# modules/vpc/variables.tf
variable "name" { type = string }
variable "cidr" { type = string, default = "10.0.0.0/16" }
variable "azs" { type = list(string) }
# modules/vpc/main.tf
resource "aws_vpc" "this" {
cidr_block = var.cidr
enable_dns_support = true
enable_dns_hostnames = true
tags = { Name = var.name }
}
# modules/vpc/outputs.tf
output "vpc_id" { value = aws_vpc.this.id }
Example 2: Remote State Backend
terraform {
backend "s3" {
bucket = "my-tf-state"
key = "prod/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "tf-lock"
encrypt = true
}
}
Best Practices
- ✅ Do: Pin provider versions in
versions.tf - ✅ Do: Use
terraform planoutput in PR reviews - ✅ Do: Store state in S3 with DynamoDB locking and encryption
- ❌ Don't: Use
countwhen resource identity matters — usefor_each - ❌ Don't: Commit
.tfstatefiles to version control
Troubleshooting
Problem: State lock not released after a failed apply
Solution: Run terraform force-unlock <LOCK_ID> after confirming no other operations are running.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
常见问题
什么是 Terraform?
Terraform 是一个工具,让你可以用代码文件来描述和管理云端基础设施(比如服务器、网络、数据库),而不必一直在图形界面里点来点去。
什么是 Terraform 模块?
模块就像一个“软件包”,里面是用来完成特定任务(例如创建网络)的 Terraform 代码。这样你就可以在多个项目中复用同一份代码。
为什么要使用远程状态?
远程状态用来保存 Terraform 所管理的基础设施信息。把它存放在远程位置(比如 AWS S3)并配合锁机制(DynamoDB),可以防止多人同时修改基础设施,从而避免出错。
详情
作者的原始描述
Terraform module creation for AWS — reusable modules, state management, and HCL best practices. Use when building or reviewing Terraform AWS infrastructure.
热度
- GitHub 星标
- 48k
- 排名
- #5959
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。