Serverless web application for uploading files to S3
Prerequisites: Node.js and AWS CLI installed
- Create an AWS Account and IAM User with the
AdministratorAccess
AWS Managed Policy - Run
aws configure
to put store that user's credentials in~/.aws/credentials
- Create an S3 bucket for storing the Lambda code and store its name in a shell variable with:
export CODE_BUCKET=bucket
- Create an S3 bucket for saving the uploaded files, store its name in shell variable:
export DEST_BUCKET=bucket
- Npm install:
npm install
- Build:
npm run build
- Upload package to S3, transform the CloudFormation template:
npm run package
- Deploy to CloudFormation:
npm run deploy
- Create the code and destination buckets
- Hit "Deploy" from the application page
- Go to API Gateway in the AWS Console to find the invoke URL and open it in your browser.
- Files you upload will be stored in the configured S3 bucket
- Optionally, you can set up a custom domain
- serverless-galleria on Github
- uploader on the AWS Serverless Application Repository
Uploads happen in a single post. The lambda invocation payload limit is 6 MB, and it gets transferred into lambda with base64 encoding, which adds 33% overhead, in addition to the rest of the payload. The expected maximum upload size is around 4 MB.
© 2017-2023 Evan Chiu. This project is available under the terms of the MIT license.