- Newest
- Most votes
- Most comments
Yes, it is possible to upload files to S3 through your Application Load Balancer (ALB) using a custom domain name that matches the ALB's CNAME. This can be achieved by combining presigned URLs with your existing architecture. Here's how you can approach this:
-
Generate presigned URLs for S3 uploads using a Lambda function behind your API Gateway. When generating these URLs, use the domain name of your ALB instead of the public S3 domain.
-
Configure your ALB to route requests. Set up rules to send API requests to the API Gateway for generating presigned URLs, and configure a default route to send traffic intended for S3 towards the VPC endpoint for S3.
-
Ensure that your S3 bucket has the same name as the domain you're using. This is important for the VPC endpoint to correctly route the presigned URL requests.
-
When a client receives the presigned URL (which will contain your ALB's domain), they can use it to upload files directly through the ALB. The ALB will then route this traffic to the S3 VPC endpoint.
This setup allows you to maintain your desired URL structure while leveraging the power of presigned URLs for S3 uploads. It avoids the 6MiB Lambda limit you encountered with multipart uploads through API Gateway.
Keep in mind that you'll need to properly secure your presigned URLs, as they grant temporary access to perform specific S3 actions. Also, ensure that your VPC endpoint for S3 is correctly configured to allow the necessary actions.
This solution provides a secure way to upload files to S3 through your private network without internet traversal, enhancing security for sensitive data transfers.
Sources
Set up private access to an Amazon S3 bucket through a VPC endpoint - AWS Prescriptive Guidance
Custom domain names for HTTP APIs in API Gateway - Amazon API Gateway
Generating a presigned URL to upload an object to an S3 on Outposts bucket - Amazon S3 on Outposts
Relevant content
asked a year ago

Does this mean, for example, if the custom CNAME is “uploads.domain.com”, the bucket will need to be called “uploads.domain.com”?
Is there a way for to change this behaviour to use a different bucket name?