Amazon Bedrock calls via AWS AppSync & AWS Lambda streaming for long tasks

AWS AppSync → AWS Lambda → Amazon Bedrock

Asynchronous streaming pattern using AWS AppSync subscriptions with Lambda to stream Amazon Bedrock responses to clients via WebSocket.

The pattern implements an asynchronous streaming architecture.
Client initiates a WebSocket subscription and makes a request to AWS AppSync. AppSync invokes Lambda function in event mode, enabling asynchronous processing.
Lambda function streams responses from Amazon Bedrock using ConverseStream. Lambda function sends updates via mutations to AppSync. Updates are delivered to client through WebSocket subscription.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/appsync-lambda-bedrock-async-stream-subscription-cdk

Deploy

cdk deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: cdk destroy --all.

Created by:

Kaustav Dey

Kaustav Dey

Solution Architect at AWS

Follow on LinkedIn