A practical tool for developing serverless applications on AWS targeting JVM platform.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
project
src/main/scala/io/tailrec/sbt/awsfun
.gitignore
LICENSE
README.md
build.sbt
publish.sbt

README.md

sbt-aws-fun

sbt plugin to manage functions to AWS Lambda

This plugin was inspired by sbt-aws-lambda. Thanks to their great work!
The fat jar is created by sbt-assembly which is a dependency of this project.
You can get started from a template by cloning this repository sbt-aws-fn-template

If you use activator, you can create a new project from the activator template like the following:
activator new your-project-name aws-lambda-seed

Installation

Add the following to your project/plugins.sbt file:

addSbtPlugin("io.tailrec.sbt" % "sbt-aws-fun" % "0.6.0")

Add the AwsFunPlugin auto-plugin to your build.sbt:

enablePlugins(AwsFunPlugin)

This plugin uses DefaultAWSCredentialsProviderChain to retrieve the AWS credentials from your environment.
It will look for credentials in this order:

  • Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
  • Java System Properties - aws.accessKeyId and aws.secretKey
  • Credential profiles file at the default location (~/.aws/credentials)
[default]
aws_access_key_id = your_aws_access_key_id
aws_secret_access_key = your_aws_secret_access_key
  • Credentials delivered through the Amazon EC2 container service
  • Instance profile credentials delivered through the Amazon EC2 metadata service

Usage

sbt deployFunctions Deploy new AWS Lambda function(s) from the current project. The (fat) jar file will be put to your S3 bucket.

sbt undeployFunctions Undeploy existing AWS Lambda function(s) from the current project. The (fat) jar file will be removed from your S3 bucket when all functions are undeployed successfully.

Configuration

sbt-aws-fun can be configured using sbt settings

sbt setting required? Description
awsS3Bucket required The name of an S3 bucket where the lambda code will be stored
awsRoleArn optional The ARN of an IAM role to use when creating a new Lambda
awsRegion optional The name of the AWS region to connect to. Defaults to us-east-1
awsLambdaTimeout optional The Lambda timeout in seconds (1-300). Defaults to AWS default.
awsLambdaMemorySize optional The amount of memory in MB for the Lambda function (128-1536, multiple of 64). Defaults to AWS default.
awsLambdaHandlers required Sequence of Lambda names to handler functions.

When you omit awsRoleArn setting, the plugin will use the default one which is lambda_basic_execution. If it couldn't find the default one, it will create one for you. This process takes a couple seconds. Provide one if you want to save a little more time :)

Example configuration:

retrieveManaged := true

enablePlugins(AwsFunPlugin)

awsLambdaHandlers := Seq(
  "function1"   -> "io.tailrec.example.Lambda::handleRequest1",
  "function2"   -> "io.tailrec.example.Lambda::handleRequest2",
  "function3"   -> "io.tailrec.example.Lambda::handleRequest3"
)

awsS3Bucket := Some("lambda-scala")

awsLambdaMemorySize := Some(192)

awsLambdaTimeout := Some(30)

awsRoleArn := Some("arn:aws:iam::123456789000:role/lambda_basic_execution")

Publishing new versions of this plugin

This plugin uses sbt-sonatype to publish to a maven central

sbt publishSigned sonatypeRelease