Giter Site home page Giter Site logo

aws-lambda-image-resizer's Introduction

aws-lambda-image-resizer

AWS Lambda image resizer function written in Go

Create buckets

Open the S3 management console and create two buckets, one for the source images and one for the resized images:

Create source bucket

Create destination bucket

Important: S3 bucket names have to be globally unique!

Create policy

Open the IAM managment console and create a new policy:

Create policy

Create policy

Create role

Create a new role. For use case, select Lambda. Click on next and select the policy from the previous step:

Attach permission policies

Create role

Build the lambda function

$ go build resizer.go
$ zip resizer.zip resizer

This creates an archive with the resizer binary that can be uploaded as lambda function to AWS.

Create lambda function

Open the Lambda managment console and create a new function:

Create function

This takes some time. After the function is created, the following screen shold be shown:

Image resizer function

Select Upload from on the right-hand side of Code source and upload the resizer.zip archive. Next edit the Runtime settings and change the name of the handler to resizer.

Next we need to configure a trigger so that the image resizer function is called when an image is uploaded to the source bucket. Click on Configuration and select Triggers, then Add trigger:

Add trigger

We also need to add an environment variable for the destination bucket used to store the resized images:

Add environment variable

Try it

Open the S3 management console and upload an image to the source bucket:

Source image

Pasqueflower

The image resizer function should now be executed automatically and create a resized image in the destination bucket:

Source image

Pasqueflower

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.