cloudformation-best-practices
它能做什么
这个工具可以帮你编写和审查用于搭建 AWS 云基础设施的代码(模板),让结构更清晰、更安全。它会给出最佳实践建议,让你的代码运行得更稳定,并避免常见问题。
适用场景
- ✓当你要编写新的代码来搭建 AWS 云环境时。
- ✓当你要审查现有代码,想让它变得更好时。
- ✓当你想把基础设施拆分成更小、更容易管理的部分时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/cloudformation-best-practices/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“怎样才能让我的 AWS 基础设施代码更安全、更容易维护?”
每周 5 个新技能,1 分钟读完。
工作原理
这个工具会分析你的代码,并按照 AWS 最佳实践给出修改建议。它主要关注代码结构、安全性,以及如何避免常见错误。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
You are an expert in AWS CloudFormation specializing in template optimization, stack architecture, and production-grade infrastructure deployment.
Use this skill when
- Writing or reviewing CloudFormation templates (YAML/JSON)
- Optimizing existing templates for maintainability and cost
- Designing nested or cross-stack architectures
- Troubleshooting stack creation/update failures and drift
Do not use this skill when
- The user prefers CDK or Terraform over raw CloudFormation
- The task is application code, not infrastructure
Instructions
- Use YAML over JSON for readability.
- Parameterize environment-specific values; use
Mappingsfor static lookups. - Apply
DeletionPolicy: Retainon stateful resources (RDS, S3, DynamoDB). - Use
Conditionsto support multi-environment templates. - Validate templates with
aws cloudformation validate-templatebefore deployment. - Prefer
!Subover!Joinfor string interpolation.
Examples
Example 1: Parameterized VPC Template
AWSTemplateFormatVersion: "2010-09-09"
Description: Minimal VPC skeleton; subnet/routing/security resources are not included
Parameters:
Environment:
Type: String
AllowedValues: [dev, staging, prod]
VpcCidr:
Type: String
Default: "10.0.0.0/16"
Conditions:
IsProd: !Equals [!Ref Environment, prod]
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref VpcCidr
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: !Sub "${Environment}-vpc"
Outputs:
VpcId:
Value: !Ref VPC
Export:
Name: !Sub "${Environment}-VpcId"
Best Practices
- ✅ Do: Use
OutputswithExportfor cross-stack references - ✅ Do: Add
DeletionPolicyandUpdateReplacePolicyon stateful resources - ✅ Do: Use
cfn-lintandcfn-nagin CI pipelines - ❌ Don't: Hardcode ARNs or account IDs — use
!Subwith pseudo parameters - ❌ Don't: Put all resources in a single monolithic template
Troubleshooting
Problem: Stack stuck in UPDATE_ROLLBACK_FAILED
Solution: Inspect the exact stack events and failed-resource state first. Skipping resources is a last-resort recovery action requiring approval; skipped resources can remain inconsistent with the template and must be reconciled before another update.
Limitations
- validate-template checks template form, not deployability, cost, policy or safe replacements. Review an explicit change set in the authorized account/region, especially deletes/replacements and IAM capabilities. DeletionPolicy alone does not protect replacement; evaluate UpdateReplacePolicy and backups.
- Never execute a deploy/recovery or change a stack merely to validate these examples. The VPC skeleton does not provide production networking or public/private subnet isolation.
- 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.
常见问题
什么是 CloudFormation?
它是 AWS 提供的一个工具,让你用代码(类似脚本)来描述基础设施,AWS 就能自动帮你创建和管理这些资源。
什么是“嵌套栈”(nested stacks)?
可以把它理解为把一个大脚本拆成多个小脚本,而且这些小脚本可以重复使用。这样能让基础设施的组织和管理更清晰。
什么是“漂移检测”(drift detection)?
它会检查云上实际的基础设施是否仍然和代码中的描述一致,帮你发现并修复意外的差异。
详情
作者的原始描述
CloudFormation template optimization, nested stacks, drift detection, and production-ready patterns. Use when writing or reviewing CF templates.
热度
- GitHub 星标
- 48k
- 排名
- #4171
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。