-
Notifications
You must be signed in to change notification settings - Fork 1k
New serverless pattern - AppSync Async Bedrock Streaming with Lambda Event Mode #2553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New serverless pattern - AppSync Async Bedrock Streaming with Lambda Event Mode #2553
Conversation
…da-bedrock-async-stream-subscription-cdk
marcojahn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @kaustavbecs,
I've checked your PR and added a few requests for changes. Additionally I was not able to deploy you pattern (checked twice) due to failures (missing mutation, pls see comments for details).
Can you please add the file example.pattern.json (template here: https://github.com/aws-samples/serverless-patterns/tree/main/_pattern-model)?
Will re-check your PR after changes made.
...nc-stream-subscription-cdk/lib/appsync-lambda-bedrock-async-stream-subscription-cdk-stack.ts
Show resolved
Hide resolved
|
Hi @marcojahn |
marcojahn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested your example and was not able to run it due to errors. Maybe just some hard coded account IDs left. Made a few more recommendations as well.
My issue is
"logType": "RequestMapping",
User: arn:aws:sts::***:assumed-role/AppsyncLambdaBedrockAsync-InvocationHandlerServiceR-PMaxGzynGwhQ/AppsyncLambdaBedrockAsync-InvocationHandlerF4117C8-rYm0jSr942Jk is not authorized to perform: bedrock:InvokeModelWithResponseStream on resource: arn:aws:bedrock:us-west-2:***:inference-profile/us.anthropic.claude-3-5-sonnet-20241022-v2:0 because no identity-based policy allows the bedrock:InvokeModelWithResponseStream action
I think I did fix this error on my deployment. But then I was stuck running the test, not receiving chunks. Did check logs but did not found any obvious error. Can you check your PR in another AWS account and another region than us-east-1?
...nc-stream-subscription-cdk/lib/appsync-lambda-bedrock-async-stream-subscription-cdk-stack.ts
Outdated
Show resolved
Hide resolved
...nc-stream-subscription-cdk/lib/appsync-lambda-bedrock-async-stream-subscription-cdk-stack.ts
Show resolved
Hide resolved
...nc-stream-subscription-cdk/lib/appsync-lambda-bedrock-async-stream-subscription-cdk-stack.ts
Outdated
Show resolved
Hide resolved
|
@marcojahn : Can you please check now |
|
Hello @kaustavbecs, thank you for your contribution. Your PR will be merged to serverlessland.com by a DA soon. |
add pattern json file
Issue #, if available:
Description of changes:
This pattern demonstrates how to implement long-running invocations with Amazon Bedrock using AWS AppSync subscriptions and AWS Lambda in Event Mode, following the official AWS AppSync documentation pattern.
How it works
The pattern implements an asynchronous streaming architecture where:
Key Benefits
Deployment Instructions
cd appsync-lambda-bedrock-async-stream-subscription-cdkTesting
After deployment, you can test the Bedrock streaming integration using the provided test script. The script demonstrates:
Run the test script using:
You should see output similar to:
Starting subscription... Starting conversation... StartConversation response: { data: { startConversation: { conversationId: '123e4567-e89b-12d3-a456-426614174000', status: 'STARTED' } } } Received chunk: { conversationId: '123e4567-e89b-12d3-a456-426614174000', chunk: "Here's a joke for you: Why don't scientists trust atoms? Because they make" } Received chunk: { conversationId: '123e4567-e89b-12d3-a456-426614174000', chunk: 'up everything!' }Cleanup
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.