All Projects → andreasonny83 → serverless-image-rendering

andreasonny83 / serverless-image-rendering

Licence: MIT license
Image delivery with AWS Lambda ⚡

Programming Languages

javascript
184084 projects - #8 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to serverless-image-rendering

terraform-aws-lambda-function
A Terraform module for deploying and managing Lambda functions on Amazon Web Services (AWS). https://aws.amazon.com/lambda/
Stars: ✭ 37 (-13.95%)
Mutual labels:  lambda
Hands-On-Serverless-Applications-with-Go
Hands-On Serverless Applications with Go, published by Packt.
Stars: ✭ 92 (+113.95%)
Mutual labels:  lambda
ebs-snapshot-lambda
AWS lambda function to snapshot EBS volumes and purge old snapshots.
Stars: ✭ 37 (-13.95%)
Mutual labels:  lambda
website-honestly
🦄 The Red Badger website. Honestly.
Stars: ✭ 26 (-39.53%)
Mutual labels:  lambda
leaderboard-app
GitHub leaderboard for your organisation or repo (Serverless SPA)
Stars: ✭ 64 (+48.84%)
Mutual labels:  lambda
imprenta
An AWS lambda in python 3 that generates PDF files from HTML using jinja, pdfkit and wkhtmltopdf.
Stars: ✭ 18 (-58.14%)
Mutual labels:  lambda
workshop-serverless-graphql
[AWSKRUG Serverless Group 2019] Serverless GraphQL Workshop
Stars: ✭ 80 (+86.05%)
Mutual labels:  lambda
FancyDialog
Kotlin + DSL风格代替传统的Builder模式 诸多可配置项 高阶函数代替自定义回调接口 书写起来超级顺手
Stars: ✭ 24 (-44.19%)
Mutual labels:  lambda
lambdakiq
ActiveJob on SQS & Lambda
Stars: ✭ 131 (+204.65%)
Mutual labels:  lambda
aws-node-custom-user-pool
Serverless AWS Cognito Custom User Pool Example
Stars: ✭ 15 (-65.12%)
Mutual labels:  lambda
shelvery-aws-backups
Automating EBS RDS EC2 backups on lambda
Stars: ✭ 31 (-27.91%)
Mutual labels:  lambda
go-localstack
Go Wrapper for using localstack
Stars: ✭ 56 (+30.23%)
Mutual labels:  lambda
serverless-lumigo-plugin
Serverless monitoring and troubleshooting plugin to easily apply distributed tracing
Stars: ✭ 59 (+37.21%)
Mutual labels:  lambda
aws-lambda-scheduler
aws-lambda-scheduler is EventBridge Rule manager that lets you call any existing AWS Lambda Function you have in a set future time with pre-set parameters. Allows more rule creation than AWS limit.
Stars: ✭ 58 (+34.88%)
Mutual labels:  lambda
serverless-certificate-creator
serverless plugin to manage the certificate of your lambdas custom domain (API Gateway=
Stars: ✭ 33 (-23.26%)
Mutual labels:  lambda
docker-selenium-lambda
The simplest demo of chrome automation by python and selenium in AWS Lambda
Stars: ✭ 172 (+300%)
Mutual labels:  lambda
netlify-lambda-function-example
An example Netlify Lambda function that processes payments with Stripe.
Stars: ✭ 93 (+116.28%)
Mutual labels:  lambda
iot-button-ec2-controller
Allows the start/stop of EC2 instances using an AWS IoT button
Stars: ✭ 23 (-46.51%)
Mutual labels:  lambda
spark-java8
Java 8 and Spark learning through examples
Stars: ✭ 40 (-6.98%)
Mutual labels:  lambda
aws-is-how
Know How Guide and Hands on Guide for AWS
Stars: ✭ 27 (-37.21%)
Mutual labels:  lambda

Serverless Image Rendering

Fast image delivering system using Sharp, AWS Lambda and Serverless framework.

serverless

Demo Lambda function available here

Medium article available here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

This project requires NodeJS (at least version 6) and NPM. Node and NPM are really easy to install. To make sure you have them available on your machine, try running the following command.

$ node -v && npm -v
v10.15.1
6.9.0

You may also want to install Serverless globally on your local machine for accessing the CLI functionality and directly interact with your deployed Lambda function.

To install Serverless globally on your machine, run the following command

$ npm i -g serverless

Please, read the official Serverless documentation to know more about the installation process.

If you want to deploy your code to AWS, then you will also need an AWS account and set-up your provider credentials

Optional requisites

This project is making use of Serverless and Docker. They are both optionals however Docker will be required for deploying your local code to Lambda if you are not running this project from a Linux machine. Read the Docker section to know more about.

Installation

Start with cloning this repo on your local machine:

$ git clone https://github.com/andreasonny83/serverless-image-rendering.git
$ cd serverless-image-rendering

Then install all the Node dependencies using npm or Yarn

$ npm install
# Or using Yarn for a faster installation
$ yarn

Images Bucket

This project is making use of a pre-existing S3 bucket from where fetching the images to be processed and deliver to the client. If you don't have an S3 already, create one from your AWS dashboard and continue reading the Environment configuration section.

Usage

Environment configuration

This project contains a serverless.sample.yml file. You need to manually renamed it to serverless.yml. In order for your application to be correctly deployed to AWS, you will need to replace the BUCKET name under the environment section according to your S3 bucket name previously created.

dotENV

For your local development you will need a .env file containing your S3 bucket name. Rename the .env.sample file in this project to be .env first, then replace the your-s3-bucket-name placeholder with the correct name of your S3 Bucket.

Serving the app

$ npm run serve

This will run the Lambda function locally using serverless-offline.

Resizing your images

While running your local app, open a browser to http://localhost:3000/resize-image?status

You should be able to see a JSON information to prove that your app is actually up and running.

You can then replace the ?status endpoint with your image information.

http://localhost:3000/resize-image?f=FILE-NAME&w=WIDTH&h=HEIGHT&q=QUALITY&t=TYPE

Query string name Type Required Description
f String Yes The complete image name uploaded to your S3 bucket (eg. placeholder.jpg)
w Number No The image width
h Number No The image height
q Number No The image quality (between 1-100)
t String No The image type (default is webp) Available values are [webp, jpeg and png]

Note. If the Type is different from your original image type, it will automatically be converted into the new format.

Example

http://localhost:3000/resize-image?f=placeholder.png&w=600&q=75&t=jpeg

Assuming that you have an image called placeholder.png on your S3 bucket:

Unit testing

$ npm test

This is using Jest framework. If you want to keep running Jest in the background and watch for file change while developing use the following npm command instead:

$ npm run test:watch

Docker

The Make install command will run npm install from inside a Docker container to reproduce the same environment configuration present on AWS Lambda. Deploying the Lambda function after running npm install from your local machine will probably result on the function returning a server error if your local machine configuration is different from the one on AWS.

To make sure the npm run deploy succeeds:

  1. Clean your node_modules folder with rm -rf node_modules package-lock.json
  2. Create the Docker image with make build
  3. Run npm install from inside the Docker container with make install
  4. Then run serverless deploywithnpm run deploy`

Deployment

  1. Install serverless globally
  2. Make sure you have correctly set up your AWS credentials
  3. Install the Node dependencies with Docker by running make build to generate the Docker image, the run make install (This will run npm install from inside the Docker container using the same environment setup running on AWS)
  4. run npm run deploy to deploy your function to AWS Lambda

Log

Note. The following commands will require Serverless to be globally installed on your machine. Please read the Prerequisites section for more information.

When your Lambda function has been deployed, you will be able to easily log all the events directly inside your local terminal.

$ sls logs -f {function-name} -t

If you don't remember what's your function name, you can easily retrieve all your Lambda information running the following command from inside your project's directory.

$ sls info

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Add your changes: git add .
  4. Commit your changes: git commit -am 'Add some feature'
  5. Push to the branch: git push origin my-new-feature
  6. Submit a pull request 😎

Built With

  • VSCode
  • dotENV
  • Serverless
  • Love

License

MIT License © Andrea SonnY

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].