Skip to content

New pattern - lambda-managed-instances-bedrock-cdk#3076

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

New pattern - lambda-managed-instances-bedrock-cdk#3076
NithinChandranR-AWS wants to merge 1 commit intoaws-samples:mainfrom
NithinChandranR-AWS:NithinChandranR-AWS-feature-lambda-managed-instances-bedrock-cdk

Conversation

@NithinChandranR-AWS
Copy link
Copy Markdown

New Serverless Pattern: Lambda Managed Instances + Bedrock (CDK)

Description

Deploys a Lambda function on Managed Instances (EC2-backed compute) that invokes Amazon Bedrock (Claude) for text generation. Demonstrates a real-world Bedrock use case beyond the existing hello-world Managed Instances pattern.

Architecture

User → Lambda Function (on Managed Instances / EC2)
         ├── VPC with private subnets
         ├── CapacityProvider (ARM64 / Graviton)
         └── Bedrock InvokeModel → Claude response

Key Features

  • EC2-backed Lambda: Runs on dedicated EC2 instances with Graviton ARM64 architecture
  • VPC integration: Private subnets with NAT Gateway for Bedrock API access
  • Least-privilege IAM: Bedrock permissions scoped to inference profile ARN
  • Production-ready: 2048 MB memory (Managed Instances minimum), nodejs24.x runtime, CloudWatch logging

Bugs Found & Fixed During Deploy

  1. Managed Instances require memorySize >= 2048 MB (not the default 128 MB)
  2. Managed Instances require nodejs24.x runtime (not nodejs22.x)
  3. Function architecture: ARM_64 must match CapacityProvider architecture

Deployed & Tested ✅

Deployed to a live AWS account and tested end-to-end. Bedrock (Claude) returned a valid response via Lambda on Managed Instances.

Files

  • lib/lambda-managed-instances-bedrock-stack.ts — CDK stack
  • src/index.js — Lambda handler (Bedrock invocation)
  • example-pattern.json — Pattern metadata
  • README.md — Full documentation with architecture, deploy, and test instructions

Deploy Lambda on EC2-backed Managed Instances with Bedrock (Claude)
integration. Uses CapacityProvider L2 construct with ARM64 architecture,
VPC with private subnets, and least-privilege IAM scoped to inference
profile ARN.

Differentiates from existing hello-world pattern by demonstrating a
real-world Bedrock invocation use case on Managed Instances.
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