🚀aws-serverless-deployment
- プラグイン
- aws-serverless
- 引数
- [what are you deploying?]
- ソース
- GitHub で見る ↗
説明
AWS SAM および AWS CDK を使用したサーバーレスアプリケーションのデプロイメントを扱います。 次のようなフレーズで起動します: SAM を使用、SAM テンプレート、SAM init、SAM deploy、CDK サーバーレス、CDK Lambda コンストラクト、NodejsFunction、PythonFunction、SAM と CDK の併用、サーバーレス CI/CD パイプライン。 次のような場合に使用: SAM または CDK に特化したサーバーレス構成やデプロイ操作を行う場合。 > **注意:** サービスを選択しながら汎用的なアプリデプロイを行う場合は、代わりに `deploy-on-aws` プラグインを使用してください。
原文を表示
AWS SAM and AWS CDK deployment for serverless applications. Triggers on phrases like: use SAM, SAM template, SAM init, SAM deploy, CDK serverless, CDK Lambda construct, NodejsFunction, PythonFunction, SAM and CDK together, serverless CI/CD pipeline. For general app deployment with service selection, use deploy-on-aws plugin instead.
ユースケース
- ✓SAM または CDK でサーバーレス構成を行う
- ✓SAM テンプレートをデプロイする
- ✓Lambda 関数をコンストラクトで定義する
- ✓SAM と CDK を併用する
本文(日本語訳)
AWS サーバーレスデプロイメント
SAM または CDK を使用して、サーバーレスアプリケーションを AWS にデプロイします。 このスキルは、プロジェクトのスキャフォールディング、IaC テンプレート、CDK コンストラクトとパターン、デプロイメントワークフロー、CI/CD パイプライン、および SAM/CDK の共存について扱います。
Lambda のランタイム動作、イベントソース、オーケストレーション、オブザーバビリティ、および最適化については、aws-lambda スキル を参照してください。
リファレンスファイルの読み込みタイミング
ユーザーの作業内容に応じて、適切なリファレンスファイルを読み込んでください:
- SAM プロジェクトのセットアップ、テンプレート、デプロイメントワークフロー、ローカルテスト、または コンテナイメージ → references/sam-project-setup.md を参照
- CDK プロジェクトのセットアップ、コンストラクト、CDK テスト、または CDK パイプライン → references/cdk-project-setup.md を参照
- CDK Lambda コンストラクト、NodejsFunction、PythonFunction、または CDK Function → references/cdk-lambda-constructs.md を参照
- CDK サーバーレスパターン、API Gateway CDK、Function URL CDK、EventBridge CDK、DynamoDB CDK、または SQS CDK → references/cdk-serverless-patterns.md を参照
- SAM と CDK の共存、SAM から CDK への移行、または CDK での sam build の使用 → references/sam-cdk-coexistence.md を参照
ベストプラクティス
SAM
- 推奨: ユースケースに合った適切なテンプレートで
sam_initを使用する - 推奨: タイムアウト、メモリ、ランタイム、トレーシングのグローバルデフォルトを
Globalsセクションに設定する - 推奨: マルチ環境デプロイメントには
samconfig.tomlの環境別セクションを使用する - 推奨: ネイティブ依存関係が含まれる場合は
sam build --use-containerを使用する - 非推奨: リソース設定を理解せずにインターネットからテンプレートをコピー&ペーストする
- 非推奨: テンプレートにリソースの ARN やアカウント ID をハードコードする —
!Ref、!GetAtt、!Subを使用すること
CDK
- 推奨: TypeScript を使用する — 型チェックにより、AWS API 呼び出しの前のシンセサイズ時にエラーを検出できる
- 推奨: L1 コンストラクトや生の IAM ステートメントより、L2 コンストラクトと
grant*メソッドを優先する - 推奨: ステートフルなリソースとステートレスなリソースを別々のスタックに分離し、ステートフルなスタックには削除保護を有効にする
- 推奨:
cdk.context.jsonをバージョン管理にコミットする — VPC/AZ のルックアップをキャッシュし、シンセサイズを決定論的にする - 推奨:
aws-cdk-lib/assertionsでユニットテストを記述し、ステートフルなリソースの論理 ID をアサートして意図しない置き換えを検出する - 推奨: すべてのデプロイメント前に CI で
cdk diffを使用して変更内容を確認する - 非推奨: アカウント ID やリージョン文字列をハードコードする —
this.accountおよびthis.regionを使用すること - 非推奨: パイプラインを経由せずに本番環境で
cdk deployを直接使用する - 非推奨:
cdk bootstrapをスキップする — CDK ツールキットスタックがなければデプロイメントは失敗する
設定
AWS CLI のセットアップ
このスキルを使用するには、ホストマシンに AWS 認証情報が設定されている必要があります:
アクセスの確認: aws sts get-caller-identity を実行して、認証情報が有効であることを確認する
SAM CLI のセットアップ
確認: sam --version を実行する
コンテナランタイムのセットアップ
- Docker 互換のコンテナランタイムをインストールする:
sam_local_invokeおよびコンテナベースのビルドに必要 - 確認:
docker --versionやfinch --versionなど、適切なコマンドを実行する
AWS Serverless MCP サーバー
書き込みアクセスはデフォルトで有効です。
このプラグインは .mcp.json に --allow-write を設定した状態で提供されるため、MCP サーバーはユーザーに代わってプロジェクトの作成、IaC の生成、およびデプロイを行うことができます。
機密データ(Lambda や API Gateway のログなど)へのアクセスは、デフォルトでは有効になっていません。
有効にするには、.mcp.json に --allow-sensitive-data-access を追加してください。
SAM テンプレートバリデーションフック
このプラグインには、template.yaml または template.yml への編集後に自動的に sam validate を実行する PostToolUse フックが含まれています。
バリデーションが失敗した場合、エラーはシステムメッセージとして返されるため、即座に修正できます。
このフックには SAM CLI と jq のインストールが必要です。いずれかが不足している場合、バリデーションはスキップされ、システムメッセージが表示されます。
ユーザーは /hooks から無効化できます。
確認: jq --version を実行する
IaC フレームワークの選択
デフォルト: CDK
上書きの構文:
- 「CloudFormation を使用」→ YAML テンプレートを生成
- 「SAM を使用」→ YAML テンプレートを生成
指定がない場合は、常に CDK を使用すること
CDK の言語選択
デフォルト: TypeScript
上書きの構文:
- 「Python を使用」→ Python コードを生成
- 「JavaScript を使用」→ JavaScript コードを生成
指定がない場合は、常に TypeScript を使用すること
エラーシナリオ
Serverless MCP サーバーが利用不可の場合
- ユーザーへの通知: 「AWS Serverless MCP が応答していません」
- 確認: 「MCP サポートなしで続行しますか?」
- ユーザーの確認なしに続行しないこと
リソース
原文(English)を表示
AWS Serverless Deployment
Deploy serverless applications to AWS using SAM or CDK. This skill covers project scaffolding, IaC templates, CDK constructs and patterns, deployment workflows, CI/CD pipelines, and SAM/CDK coexistence.
For Lambda runtime behavior, event sources, orchestration, observability, and optimization, see the aws-lambda skill.
When to Load Reference Files
Load the appropriate reference file based on what the user is working on:
- SAM project setup, templates, deployment workflow, local testing, or container images -> see references/sam-project-setup.md
- CDK project setup, constructs, CDK testing, or CDK pipelines -> see references/cdk-project-setup.md
- CDK Lambda constructs, NodejsFunction, PythonFunction, or CDK Function -> see references/cdk-lambda-constructs.md
- CDK serverless patterns, API Gateway CDK, Function URL CDK, EventBridge CDK, DynamoDB CDK, or SQS CDK -> see references/cdk-serverless-patterns.md
- SAM and CDK coexistence, migrating from SAM to CDK, or using sam build with CDK -> see references/sam-cdk-coexistence.md
Best Practices
SAM
- Do: Use
sam_initwith an appropriate template for your use case - Do: Set global defaults for timeout, memory, runtime, and tracing in the
Globalssection - Do: Use
samconfig.tomlenvironment-specific sections for multi-environment deployments - Do: Use
sam build --use-containerwhen native dependencies are involved - Don't: Copy-paste templates from the internet without understanding the resource configuration
- Don't: Hardcode resource ARNs or account IDs in templates — use
!Ref,!GetAtt, and!Sub
CDK
- Do: Use TypeScript — type checking catches errors at synthesis time, before any AWS API calls
- Do: Prefer L2 constructs and
grant*methods over L1 and raw IAM statements - Do: Separate stateful and stateless resources into different stacks; enable termination protection on stateful stacks
- Do: Commit
cdk.context.jsonto version control — it caches VPC/AZ lookups for deterministic synthesis - Do: Write unit tests with
aws-cdk-lib/assertions; assert logical IDs of stateful resources to detect accidental replacements - Do: Use
cdk diffin CI before every deployment to review changes - Don't: Hardcode account IDs or region strings — use
this.accountandthis.region - Don't: Use
cdk deploydirectly in production without a pipeline - Don't: Skip
cdk bootstrap— deployments will fail without the CDK toolkit stack
Configuration
AWS CLI Setup
This skill requires that AWS credentials are configured on the host machine:
Verify access: Run aws sts get-caller-identity to confirm credentials are valid
SAM CLI Setup
Verify: Run sam --version
Container Runtime Setup
- Install a Docker compatible container runtime: Required for
sam_local_invokeand container-based builds - Verify: Use an appropriate command such as
docker --versionorfinch --version
AWS Serverless MCP Server
Write access is enabled by default. The plugin ships with --allow-write in .mcp.json, so the MCP server can create projects, generate IaC, and deploy on behalf of the user.
Access to sensitive data (like Lambda and API Gateway logs) is not enabled by default. To grant it, add --allow-sensitive-data-access to .mcp.json.
SAM Template Validation Hook
This plugin includes a PostToolUse hook that runs sam validate automatically after any edit to template.yaml or template.yml. If validation fails, the error is returned as a system message so you can fix it immediately. The hook requires SAM CLI and jq to be installed; if either is missing, validation is skipped with a system message. Users can disable it via /hooks.
Verify: Run jq --version
IaC framework selection
Default: CDK
Override syntax:
- "use CloudFormation" → Generate YAML templates
- "use SAM" → Generate YAML templates
When not specified, ALWAYS use CDK
Language selection for CDK
Default: TypeScript
Override syntax:
- "use Python" → Generate Python code
- "use JavaScript" → Generate JavaScript code
When not specified, ALWAYS use TypeScript
Error Scenarios
Serverless MCP Server Unavailable
- Inform user: "AWS Serverless MCP not responding"
- Ask: "Proceed without MCP support?"
- DO NOT continue without user confirmation
Resources
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。