GithubHelp home page GithubHelp logo

tranvelocity / image-resizer-lambda-serverless Goto Github PK

View Code? Open in Web Editor NEW

This project forked from samuraikun/image-resizer-lambda-serverless

0.0 1.0 0.0 6 KB

AWS Lambda to resize image by Serverless Framework

Ruby 100.00%

image-resizer-lambda-serverless's Introduction

image-resizer-lambda-serverless

AWS Lambda to resize image when upload image to specific S3 bucket.

Runtime

  • Ruby2.7

Deploy & Resource Setting

  • Serverless Framework

Setup

required

  • Docker
  • AWS Account & AWS CLI

Add AWS credential

$ touch docker.env

docker.env

AWS_ACCESS_KEY_ID=xxx
AWS_DEFAULT_REGION=ap-northeast-1
AWS_SECRET_ACCESS_KEY=xxx

docker-compose

$ docker-compose build
$ docker-compose --rm run serverless sh

sh-4.2# bundle config set path 'vendor/bundle'
sh-4.2# bundle install

Debug Lambda

use bundle exec ruby in docker-compose

For example, you insert binding.irb in handler.rb for debug.

You command below

sh-4.2# bundle exec ruby handler.rb

docker-lambda

  • WIP

Deploy

sh-4.2# sls deploy

# Remove Resources
sh-4.2# sls remove

Lambda Layer

deploy libvips to lambda layer for native extendions.

use https://github.com/customink/ruby-vips-lambda

$ git clone https://github.com/customink/ruby-vips-lambda.git
$ cd ruby-vips-lambda
$ ./bin/deploy

If you deploy to layer other region(not us-east-1)

  • change AWS_DEFAULT_REGION in ruby-vips-lambda/bin/deploy
#!/bin/bash

set -e

./bin/build

export VIPS_VERSION=$(cat share/VIPS_VERSION)
export LAYER_NAME="rubyvips${VIPS_VERSION//./}-27"

# change here
export AWS_REGION=${AWS_REGION:=ap-northeast-1}

aws lambda publish-layer-version \
  --region $AWS_REGION \
  --layer-name $LAYER_NAME \
  --description "Libvips for Ruby FFI." \
  --zip-file "fileb://share/libvips.zip"

image-resizer-lambda-serverless's People

Contributors

samuraikun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.