Skip to content

Add lambda-s3-download pattern for streaming URL downloads to S3#2956

Open
roblOnTour wants to merge 1 commit intoaws-samples:mainfrom
roblOnTour:roblontour-feature-lambda-s3-download
Open

Add lambda-s3-download pattern for streaming URL downloads to S3#2956
roblOnTour wants to merge 1 commit intoaws-samples:mainfrom
roblOnTour:roblontour-feature-lambda-s3-download

Conversation

@roblOnTour
Copy link

Issue #, if available:
N/A

Description of changes:

New pattern: lambda-s3-download

A Lambda function (Python 3.12) that downloads a file from a URL and uploads it to S3 using multipart upload with SHA256 checksums. The file is streamed in configurable chunks through /tmp, allowing it to handle files larger than Lambda's memory limit.

Features:

  • Chunked streaming download with configurable chunk size (clamped between 5 MB and 5 GB)
  • S3 multipart upload with SHA256 checksum verification
  • Automatic cleanup of incomplete multipart uploads on failure
  • 15-minute timeout, 1 GB memory, 10 GB ephemeral storage

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Contributor

@biswanathmukherjee biswanathmukherjee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be more review comments :)

@@ -0,0 +1,96 @@
# Lambda S3 Download
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please provide a meaningful title.
  2. Also use the full AWS Service name e.g. AWS Lambda function, Amazon S3

@@ -0,0 +1,96 @@
# Lambda S3 Download

This pattern deploys a Lambda function that downloads a file from a URL and uploads it to an S3 bucket using multipart upload. It streams the file in configurable chunks through `/tmp`, making it capable of handling files larger than Lambda's memory and storage limits.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description says it is 'upload' to S3 functionality, however, the folder name has 'download'. Sounds contradicting?

aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus"
```
----
Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2026

@@ -0,0 +1,60 @@
{
"title": "Lambda S3 Download",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please provide a meaningful title.
  2. Also use the full AWS Service name e.g. AWS Lambda function, Amazon S3
  3. Title should be <= 70 char long

```
1. Build the application:
```
sam build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build failed with the following error

python3.12 architecture: x86_64 functions: DownloadFunction
Running PythonPipBuilder:ResolveDependencies

Build Failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants