feat(lambda-durable-bedrock-async-invoke-cdk) new pattern#2984
Open
bfreiberg wants to merge 4 commits intoaws-samples:mainfrom
Open
feat(lambda-durable-bedrock-async-invoke-cdk) new pattern#2984bfreiberg wants to merge 4 commits intoaws-samples:mainfrom
bfreiberg wants to merge 4 commits intoaws-samples:mainfrom
Conversation
embano1
reviewed
Mar 16, 2026
|
|
||
| This pattern shows how to use AWS Lambda durable functions to orchestrate [Amazon Bedrock Async Invoke](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_StartAsyncInvoke.html) for AI video generation. The durable function starts an Amazon Nova Reel video generation job, then polls for completion using `waitForCondition` with exponential backoff. During each polling interval the function suspends execution entirely, incurring zero compute charges while Bedrock processes the video. | ||
|
|
||
| Without durable functions this pattern would require a separate polling mechanism such as Step Functions, EventBridge rules, or a cron-based poller. Here the entire workflow is a single, linear function that reads top-to-bottom. |
Contributor
There was a problem hiding this comment.
Suggested change
| Without durable functions this pattern would require a separate polling mechanism such as Step Functions, EventBridge rules, or a cron-based poller. Here the entire workflow is a single, linear function that reads top-to-bottom. | |
| Without durable functions this pattern would require separate polling mechanism such as in-process waiting (charging for idle time) or additional infrastructure for orchestration or cron schedules. Here the entire workflow is a single, linear function that reads top-to-bottom. |
|
|
||
| Once the status shows `SUCCEEDED`, the result will contain the S3 URI where the video was written. | ||
|
|
||
| ### Run unit tests |
Contributor
There was a problem hiding this comment.
oh, just saw we have that - should be moved up before deployment
| error: error.message, | ||
| prompt: event.prompt, | ||
| }); | ||
| throw error; |
Contributor
There was a problem hiding this comment.
note: will fail the execution, if that's what we want (perhaps yes?)
Contributor
Author
There was a problem hiding this comment.
This is the right behavior in my opinion because:
- The error has already exhausted any step-level retries (configured via bedrockRetryStrategy / defaultRetryStrategy)
- Re-throwing surfaces the failure to the caller via the durable execution status
- It matches the error handling from our official guidance
…figuration and testing guidance - Add Configuration section documenting environment variables (BEDROCK_MODEL_ID, BEDROCK_REGION, OUTPUT_BUCKET_NAME) - Include table with variable defaults and descriptions for clarity - Move unit test instructions earlier in deployment workflow (before CDK deploy) - Clarify that tests verify both CDK infrastructure and durable handler functionality - Update pattern description to better explain polling alternatives and cost benefits
…ons and update paths - Add log file exclusions to .gitignore (error.log, combined.log) - Update README documentation links and directory paths to reflect -cdk suffix - Update example-pattern.json repository and project folder references to -cdk variant - Refactor IAM policy statements to scope Bedrock permissions to Nova Reel model ARN - Split GetAsyncInvoke permission into separate policy statement scoped to invocation ARNs - Update test to verify scoped Bedrock permissions are correctly applied - Improves security posture by following principle of least privilege for Bedrock access
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available: #2986
Description of changes:
This pattern shows how to use AWS Lambda durable functions to orchestrate Amazon Bedrock Async Invoke for AI video generation. The durable function starts an Amazon Nova Reel video generation job, then polls for completion using
waitForConditionwith exponential backoff. During each polling interval the function suspends execution entirely, incurring zero compute charges while Bedrock processes the video.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.