Skip to content

New pattern - Lambda SnapStart with Amazon Bedrock (CDK)#3082

Open
NithinChandranR-AWS wants to merge 1 commit intoaws-samples:mainfrom
NithinChandranR-AWS:NithinChandranR-AWS-feature-lambda-snapstart-bedrock-cdk
Open

New pattern - Lambda SnapStart with Amazon Bedrock (CDK)#3082
NithinChandranR-AWS wants to merge 1 commit intoaws-samples:mainfrom
NithinChandranR-AWS:NithinChandranR-AWS-feature-lambda-snapstart-bedrock-cdk

Conversation

@NithinChandranR-AWS
Copy link
Copy Markdown

Description

This pattern deploys a Python 3.13 Lambda function with SnapStart enabled that invokes Amazon Bedrock (Claude Sonnet) for text generation, using AWS CDK.

Key Features

  • Lambda SnapStart via SnapStartConf.ON_PUBLISHED_VERSIONS — reduces cold start latency by up to 10x
  • Published version + live alias (SnapStart only applies to published versions, not $LATEST)
  • boto3 client initialized at module level for snapshot capture
  • Inference profile model ID with scoped IAM permissions
  • JSON structured logging with 2-week retention

Architecture

Lambda (Python 3.13, SnapStart) ──▶ Amazon Bedrock (Claude Sonnet)

Testing

Deployed and tested on AWS account. Verified:

  • ExecutedVersion: 1 confirms invocation through SnapStart-optimized alias
  • Successful Bedrock Claude Sonnet response with usage metadata
  • SnapStart alias shows Restore Duration instead of Init Duration in CloudWatch Logs

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation (README.md)
  • My changes generate no new warnings
  • New and existing tests pass locally with my changes
  • example-pattern.json included

Python 3.13 Lambda function with SnapStart enabled that invokes
Amazon Bedrock Claude Sonnet for text generation. SnapStart reduces
cold start latency by up to 10x via execution environment snapshots.

- SnapStartConf.ON_PUBLISHED_VERSIONS with version + live alias
- boto3 client initialized at module level for snapshot capture
- Inference profile model ID with scoped IAM permissions
- JSON structured logging with 2-week retention
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants