Coder Social home page Coder Social logo

localstack-demo's Introduction

Invoke a lambda function to upload an image to S3

This example shows how to invoke a lambda function to upload an image to S3

Requirements

You should have installed:

  • Install Docker if you haven't already.
  • Install Serverless framework.
  • Install the AWS CLI. Although we aren't going to work with "real" AWS, we'll need it to talk with our local docker containers.
  • Once the AWS CLI is installed, run the following command to create some credentials. You can use real credentials, or dummy ones. Localstack requires that these values are present, but it doesn't actually validate them.
aws configure

Prepare environment

Run Localstack. You can customize it in docker-compose.yml file.

docker-compose up -d

We need to create the S3 bucket where we are going to upload the image

sh prepare_environment.sh

Deploy

In order to deploy the example, simply run:

sls deploy --stage local --region us-east-1

## Usage

We can invoke the lambda function with the following command:

sls invoke -f uploadImageToS3 --stage local

The output should be like that:

Serverless: Using serverless-localstack
{
    "path": "images/upload.png"
}

Where the path is the route to access to the file. So just open your browser and type:

http://localhost:4572/tutorial/images/upload.png

References

Localstack: https://github.com/localstack/localstack Serverless: https://serverless.com Localstack Serverless Plugin: https://github.com/localstack/serverless-localstack AWS CLI: https://docs.aws.amazon.com/cli/latest/reference/

localstack-demo's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

localstack-demo's Issues

Readme

Suggest that for now we lock down to version 0.10.8 of localstack as the new version of serverless-localstack seems incompatible

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.