Aws Serverless Deployment

作者 awslabs097fe8ad56d8无许可证915 个星标收录于 2026年10月8日更新于 2026年10月8日仓库今天更新

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.

仅含说明DevOps & Cloud
AI 生成的概览

指导使用 AWS SAM 和 CDK 部署无服务器应用,涵盖项目脚手架、IaC 模板、构造和 CI/CD。

功能
该技能提供使用 AWS SAM 或 AWS CDK 将无服务器应用部署到 AWS 的说明。内容涵盖项目脚手架、基础设施即代码模板、CDK 构造与无服务器模式、部署工作流、CI/CD 流水线以及 SAM 与 CDK 共存。它会根据用户处理的是 SAM 设置、CDK 设置、Lambda 构造、无服务器模式还是 SAM 迁移到 CDK,将用户引导至随附的参考文件。
适用场景
适用于使用 SAM 或 CDK 将无服务器应用部署到 AWS 的场景,包括 SAM 模板、CDK Lambda 构造、无服务器 CI/CD 流水线或 SAM 与 CDK 共存。它不适用于需要选择服务的通用应用部署,文档中将其指向另一个插件。
运行要求
需要在主机上配置 AWS 凭证、AWS CLI、SAM CLI,以及用于本地调用和基于容器的构建的 Docker 兼容容器运行时。SAM 模板验证钩子需要 SAM CLI 和 jq。它还引用了一个默认启用写入权限的 AWS Serverless MCP 服务器。该技能不附带脚本,仅为说明和参考文档。

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 [blocked]
  • CDK project setup, constructs, CDK testing, or CDK pipelines -> see references/cdk-project-setup.md [blocked]
  • CDK Lambda constructs, NodejsFunction, PythonFunction, or CDK Function -> see references/cdk-lambda-constructs.md [blocked]
  • CDK serverless patterns, API Gateway CDK, Function URL CDK, EventBridge CDK, DynamoDB CDK, or SQS CDK -> see references/cdk-serverless-patterns.md [blocked]
  • SAM and CDK coexistence, migrating from SAM to CDK, or using sam build with CDK -> see references/sam-cdk-coexistence.md [blocked]

Best Practices

SAM

  • Do: Use sam_init with an appropriate template for your use case
  • Do: Set global defaults for timeout, memory, runtime, and tracing in the Globals section
  • Do: Use samconfig.toml environment-specific sections for multi-environment deployments
  • Do: Use sam build --use-container when 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.json to 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 diff in CI before every deployment to review changes
  • Don't: Hardcode account IDs or region strings — use this.account and this.region
  • Don't: Use cdk deploy directly 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

  1. Install a Docker compatible container runtime: Required for sam_local_invoke and container-based builds
  2. Verify: Use an appropriate command such as docker --version or finch --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

来源与署名

来源:awslabs/agent-plugins位于plugins/aws-serverless/skills/aws-serverless-deployment提交097fe8a

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架