Giter Site home page Giter Site logo

demoawslambdasbt's Introduction

demoAwsLambdaSbt

This is an sbt based project that demonstrates how simple it is to write and deploy AWS Lambda functions in scala thanks to sbt and its plug-ins!

To use this project

  • Start with a git clone of the project
  • Then use sbt and the createLambda or updateLambda tasks from the sbt prompt. NOTE: you will be prompted for an S3 bucket for the .jar to be put in, you'll need to chose one in your account. (The bucket name must be all lower case and cannot contain special characters like underscore)
  • Next use the Aws Lambda Management Console test your code. The "trick" here is to select the "S3 Put" event in their template of test events.
  • You will see that the code pulls out the value of the field Records.s3.key which is by default "HappyFace.jpg"
  • For more advanced AWS operations consider using the aws java sdk or the more 'Scala-ey' aws-scala-sdk

For background information about the underlying libraries see the sbt-aws-lambda github project.

The original scala code inspiration for this project was described in this article written by Tim Wagner, AWS Lambda General Manager and Sean Reque an AWS Lambda Software Developer.

The sbt-aws-lambda plug-in developed by gilt engineering makes it VERY EASY to create and update AWS Lambda functions.

Finally, the sbt-aws-lambda plug-in can be configured using sbt settings, environment variables or by reading user input at deploy time. For example if you use this project as published, sbt will prompt you for the s3 bucket to use and query you as to the IAM role to use for your lambda function. That's all you really need to get started, but if you want more control you can set the following values.

sbt setting Environment variable Description
s3Bucket AWS_LAMBDA_BUCKET_ID The name of an S3 bucket where the lambda code will be stored
lambdaName AWS_LAMBDA_NAME The name to use for this AWS Lambda function. Defaults to the project name
handlerName AWS_LAMBDA_HANDLER_NAME Java class name and method to be executed, e.g. com.gilt.example.Lambda::myMethod
roleArn AWS_LAMBDA_IAM_ROLE_ARN The ARN of an IAM role to use when creating a new Lambda
region AWS_REGION The name of the AWS region to connect to. Defaults to us-east-1
awsLambdaTimeout The Lambda timeout in seconds (1-300). Defaults to AWS default.
awsLambdaMemory The amount of memory in MB for the Lambda function (128-1536, multiple of 64). Defaults to AWS default.
lambdaHandlers Sequence of Lambda names to handler functions (for multiple lambda methods per project). Overrides lambdaName and handlerName if present.

Note: your aws credentials will be picked up as normal if you use the aws cli as sbt-aws-lambda plug-in uses the AWS SDK for Java.

demoawslambdasbt's People

Contributors

langley avatar

Watchers

 avatar  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.