本文へスキップ
Skillpedia
デプロイとクラウド(DevOps)48k · #4171

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に貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/cloudformation-best-practices/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

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

  1. Use YAML over JSON for readability.
  2. Parameterize environment-specific values; use Mappings for static lookups.
  3. Apply DeletionPolicy: Retain on stateful resources (RDS, S3, DynamoDB).
  4. Use Conditions to support multi-environment templates.
  5. Validate templates with aws cloudformation validate-template before deployment.
  6. Prefer !Sub over !Join for 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 Outputs with Export for cross-stack references
  • ✅ Do: Add DeletionPolicy and UpdateReplacePolicy on stateful resources
  • ✅ Do: Use cfn-lint and cfn-nag in CI pipelines
  • ❌ Don't: Hardcode ARNs or account IDs — use !Sub with 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.

repo: sickn33/agentic-awesome-skills

人気

GitHubのスター
48k
ランキング
#4171
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル