{"id":21252578,"url":"https://github.com/cartercobb/file-to-zip-lambda-serverless","last_synced_at":"2026-05-18T03:34:07.613Z","repository":{"id":130567831,"uuid":"471132535","full_name":"CarterCobb/File-to-Zip-Lambda-Serverless","owner":"CarterCobb","description":"AWS Lambda to convert new files to zip files.","archived":false,"fork":false,"pushed_at":"2022-03-20T19:35:44.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-01T14:43:13.099Z","etag":null,"topics":["aws-lambda","aws-s3","node-js","serverless"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CarterCobb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-17T20:28:36.000Z","updated_at":"2022-03-18T21:04:30.000Z","dependencies_parsed_at":"2023-03-23T09:19:56.227Z","dependency_job_id":null,"html_url":"https://github.com/CarterCobb/File-to-Zip-Lambda-Serverless","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CarterCobb/File-to-Zip-Lambda-Serverless","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarterCobb%2FFile-to-Zip-Lambda-Serverless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarterCobb%2FFile-to-Zip-Lambda-Serverless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarterCobb%2FFile-to-Zip-Lambda-Serverless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarterCobb%2FFile-to-Zip-Lambda-Serverless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CarterCobb","download_url":"https://codeload.github.com/CarterCobb/File-to-Zip-Lambda-Serverless/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarterCobb%2FFile-to-Zip-Lambda-Serverless/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33163755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"online","status_checked_at":"2026-05-18T02:00:06.436Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","aws-s3","node-js","serverless"],"created_at":"2024-11-21T03:47:59.479Z","updated_at":"2026-05-18T03:34:07.608Z","avatar_url":"https://github.com/CarterCobb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS S3 Lambda Zipper\n\nThis project contains an example for an [AWS Lambda](https://aws.amazon.com/lambda/) that is triggered on an [AWS S3](https://aws.amazon.com/s3/) bucket create event. The lambda takes the new file, converts it to a zip file and re-uploads it back to the AWS S3 bucket.\n\n## Technology Stack\n\n- [NodeJS](https://nodejs.org/en/)\n- [Serverless](https://www.serverless.com/)\n- [AWS Lambda](https://aws.amazon.com/lambda/)\n- [AWS S3](https://aws.amazon.com/s3/)\n\n## Prerequisites\n\n- An AWS account [sign up here](https://portal.aws.amazon.com/billing/signup#/start/email)\n- AWS CLI installed and configured [demo here](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html)\n- NodeJS installed [install here](https://nodejs.org/en/download/)\n- Serverless installed and configured [demo here](https://www.serverless.com/framework/docs/getting-started)\n\n## Initial Setup\n\nThis lambda requires initial setup before you can deploy the system using Serverless. Follow these steps:\n\n- (required) cd into the `./layer/nodejs` folder and run `npm i`\n  - This is required due to it being a fundamental part of creating the Lambda Layer -\u003e Layer for NodeJS dependencies\n- (optional - used for local testing) In the root directory run `npm i`\n\nBoth those steps install the NodeJs dependencies for the project. More specifically [archiver](https://www.npmjs.com/package/archiver) \u0026 [stream](https://www.npmjs.com/package/stream).  \n\n\u003e Important!\n\n(optional) If you prefer to use Environment Variables to hide your resource names:\n\n- Create a `.env` file in the root directory\n- Add variables to store each AWS S3 bucket name. e.g. `BUCKET=my-s3-bucket`\n  - Do this for each bucket you wish to attach to the lambda as a trigger. Be sure to name each variable different\n\nSome files require you to use your AWS credentials and resource names. Those are as follows:\n\n- [`serverless.yml`](https://github.com/CarterCobb/File-to-Zip-Lambda-Serverless/blob/master/serverless.yml)\n  - At the bottom of the file, there is a custom property to store bucket names\n    - Add each of your buckets under the `buckets` property. format is `${env:BUCKET_NAME_ENV_VAR, 'default if no env var'}`\n  - In the middle of the file you will see `functions: ...`\n    - Add an event to each of your AWS S3 buckets you listed in the custom property from before. Templete in file.\n  - Twards the top of the file there is an `iam` property\n    - Once again list all your buckets from the custom property you defined under the `Resource` property. Templete in file.\n- [`handler.js`](https://github.com/CarterCobb/File-to-Zip-Lambda-Serverless/blob/master/handler.js)\n  - The only edit required is the AWS region your S3 bucket resides in.\n    - At the top of the file change `const s3 = new AWS.S3({ region: \"\u003cYOUR_AWS_REGION\u003e\" });`\n\nOther edits can be made such as the location the zip file get stored when it is uploaded to the S3 bucket. Refer to the JSDocs in [`handler.js`](https://github.com/CarterCobb/File-to-Zip-Lambda-Serverless/blob/master/handler.js) to change/edit that configuiration.\n\n## Deploy to AWS\n\nThis is the easiest part.\n\n- Simply run `serverless deploy` in the root directory.\n\nAssuming AWS CLI is confiugured and no issues with credentials are found the lambda will be created and deplotyed to your account.\n\nThings you will notice:\n\n- The Lambda will have 1 layer. That is the NodeJS dependancies.\n- The lambda will have at least one event pointing to a S3 bucket.\n- You will see a CloudFormation stack that handles the upload.\n- A seperate lambda will be created with a random looking name.\n- A seperate AWS S3 bucket will be created that also has a random looking name.\n\nLeave all of these things alone as they are helpers for Serverless to delpoy and re-deploy the system.\n\n## Remove the AWS Deployment\n\nTo tear down and destroy all resources that were created\n\n- Simply run `serverless remove` in the root directory.\n\n## Logic Behind the Lambda\n\nPlease refer to the JSDocs in the [`handler.js`](https://github.com/CarterCobb/File-to-Zip-Lambda-Serverless/blob/master/handler.js) file.\n\n## Additional Details\n\nThis was built to assist a fellow developer with the logic base in the Lambda function and how Serverless opperates. Thus, this project is Open Source and free to be used and copied by all.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcartercobb%2Ffile-to-zip-lambda-serverless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcartercobb%2Ffile-to-zip-lambda-serverless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcartercobb%2Ffile-to-zip-lambda-serverless/lists"}