Skip to content

New serverless pattern - s3-multipart-getpart-sqs-lambda-typescript-cdk - #3569

Open
NithinChandranR-AWS wants to merge 1 commit into
aws-samples:mainfrom
NithinChandranR-AWS:NithinChandranR-AWS-feature-s3-multipart-getpart-sqs-lambda-cdk
Open

NithinChandranR-AWS wants to merge 1 commit into
aws-samples:mainfrom
NithinChandranR-AWS:NithinChandranR-AWS-feature-s3-multipart-getpart-sqs-lambda-cdk

Conversation

@NithinChandranR-AWS

Copy link
Copy Markdown
Contributor

Description

Process Amazon S3 multipart upload parts while the upload is in progress with Amazon SQS and AWS Lambda. Amazon S3 sends each s3:MultipartUpload:PartUploaded event to an Amazon SQS queue, and an AWS Lambda function reads that part with the new Amazon S3 GetPart API before the upload completes, hashes it and records it in an Amazon DynamoDB part ledger that the completion or abort event closes. Claim issue: #3568.

Key Innovation

Uses the s3:MultipartUpload:PartUploaded event and the GetPart API (announced 2026-11-29) to read parts during the upload. The nearest existing pattern, s3-sqs-lambda-dynamodb, processes whole objects after ObjectCreated; this one reads each part while the upload runs and keeps the ledger correct under duplicate, out-of-order and superseded part events.

Architecture

Amazon S3 (PartUploaded, Aborted, CompleteMultipartUpload) -> Amazon SQS (+ dead-letter queue) -> AWS Lambda (GetPart, SHA-256) -> Amazon DynamoDB part ledger

Deployed and Tested

Deployed in us-east-1 (~90 s), 20 CloudFormation resources. README Testing run as written in zsh and in macOS bash 3.2, with the Region set only by the README's export AWS_REGION=us-east-1:

  • Before completion: two PART rows with IN_PROGRESS and a matching SHA-256 checksum, the sha256Hex of each part equal to the local shasum of the uploaded file, an UPLOAD row IN_PROGRESS, and head-object returning 404 Not Found
  • After complete-multipart-upload: UPLOAD COMPLETE with the object size 10485760
  • Part 1 uploaded twice: the ledger holds the second ETag
  • Abort: UPLOAD ABORTED, dead-letter queue 0; the deployed queue reads maxReceiveCount 5
  • Cleanup: the abort loop aborted a left-open upload (key with a space) in both shells and printed nothing when none was open; cdk destroy left only the two CDK helper log groups that the README lists
  • Not tested: a second Region. On 2026-11-30 GetPart returned 405 MethodNotAllowed in us-east-2, us-west-2, eu-central-1, eu-west-1 and ap-southeast-1, and ap-south-1 delivered no PartUploaded events; the README Supported Regions section says so. Also not tested: UploadPartCopy (PartCopied is not subscribed, the README says so), parts larger than 5 MiB, the timeout path

Checklist

  • IAM least-privilege (s3:GetObject + s3:GetIncompleteUpload on this bucket's objects only, in-progress reads verified with the deployed role; SQS consume on one queue; PutItem/UpdateItem on one table)
  • CDK synth passes (20 resources)
  • Deployed and tested end-to-end in us-east-1
  • validate.js passes, including the admin IAM check
  • No duplicate patterns in repo

…tipart upload parts in progress with GetPart

- Amazon S3 PartUploaded, Aborted and CompleteMultipartUpload events to an Amazon SQS queue with a dead-letter queue
- AWS Lambda reads each part with GetPart while the upload is in progress, streams a SHA-256 hash, checks the S3 checksum
- Amazon DynamoDB part ledger with conditional writes for duplicate, out-of-order and superseded events
- Bundled AWS SDK for JavaScript S3 client (GetPart), explicit log group, least-privilege IAM

This branch has not been deployed

No deployments
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