Skip to content

Latest commit

 

History

History

compress

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

compress

Copy and compress images using Lambda.

Deploy with CloudFormation

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 the S3 bucket for the compressed output, store its name in shell variable:
    • export DEST_BUCKET=bucket
  • Choose a name, but do NOT create the S3 bucket input comes from, store its name in shell variable:
    • export SOURCE_BUCKET=bucket
  • Choose the JPEG compression quality, 1 to 100, 100 is best quality/largest file, (See docs), store it in shell variable:
    • export QUALITY=25
  • 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

Deploy from the AWS Serverless Application Repository

  • Create the destination bucket
  • Hit "Deploy" from the application page

Use

  • Images that you put into the source bucket will be transformed, then put into the destination bucket

Links

License

© 2017-2023 Evan Chiu. This project is available under the terms of the MIT license.