Skip to content

Commit

Permalink
Version 0.4 add deployPrebuiltLambda feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Hutchison committed Aug 2, 2017
1 parent 8b368fa commit 8f8cdfb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Otherwise, the lambda is created using [`CreateFunctionRequest`](http://docs.aws

*Note: if you remove an existing handler from the settings and run `deployLambda`, the corresponding lambda will not be cleaned up.*

`deployPrebuiltLambda` deploys an existing jar file to AWS directly without packaging. It requires the `prebuiltPath` setting
to be defined.

###Deployment Methods

Expand Down Expand Up @@ -89,6 +91,7 @@ which searches for credentials in standard locations; see linked documentation f
| awsLambdaTimeout |Optional Lambda timeout length in seconds (1-300). Optional, defaults to AWS default |
| awsLambdaMemory |Optional memory in MB for the Lambda function (128-1536, multiple of 64). Optional, defaults to AWS default |
| awsLambdaVpcConfig |Pair of lists, the first containing a list of subnet IDs the lambda needs to access, the second a list of security groups IDs in the VPC the lambda accesses. Optional |
| prebuiltPath |Local path to an existing lambda jar file. Only required by `deployPrebuiltLambda` task. |

##Change Log

Expand All @@ -97,6 +100,7 @@ which searches for credentials in standard locations; see linked documentation f
| 0.1 | Feb 2017 |Initial release |
| 0.2 | Mar 2017 |Support VpcConfig settings on lambda create|
| 0.3 | Mar 2017 |Support VpcConfig settings on lambda update|
| 0.3 | Aug 2017 |Support deployPrebuiltLambda task|

##Credits & changes vs `sbt-aws-lambda` plugin

Expand Down
16 changes: 15 additions & 1 deletion src/main/scala/com/reagroup/lambda/AwsLambdaPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ object AwsLambdaPlugin extends AutoPlugin {
val lambdaHandlers = settingKey[Map[String, String]]("Map of Lambda function names to handlers. Required")
val awsLambdaVpcConfig = settingKey[Option[(List[String], List[String])]]("Pair of lists, the first containing a list of subnet IDs the lambda needs to access, " +
"the second a list of security groups IDs in the VPC the lambda accesses. Optional")

val deployPrebuiltLambda = taskKey[Map[String, String]]("Deploy a prebuilt jar to AWS Lambda")
val prebuiltPath = settingKey[Option[String]]("Path to prebuilt jar file. Optional, only used with `deployPrebuiltLambda`")
}

import autoImport._
Expand All @@ -48,7 +51,18 @@ object AwsLambdaPlugin extends AutoPlugin {
sbtassembly.AssemblyKeys.assembly.value,
lambdaHandlers.value,
deployParamsSetting.value
)
),
prebuiltPath := None,
deployPrebuiltLambda := {
val file = new java.io.File(prebuiltPath.value.getOrElse(
sys.error("prebuiltPath setting must be defined to deployPrebuiltLambda")))
println(s"deployPrebuiltLambda from $file")
Direct.deploy(
file,
lambdaHandlers.value,
deployParamsSetting.value
)
}
)

val DeployDirect = "Direct"
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version := "0.3"
version := "0.4"

0 comments on commit 8f8cdfb

Please sign in to comment.