mhjort / clj-lambda-utils Goto Github PK
View Code? Open in Web Editor NEWClojure utilities for AWS Lambda (JVM based) deployment
License: Eclipse Public License 1.0
Clojure utilities for AWS Lambda (JVM based) deployment
License: Eclipse Public License 1.0
Sometimes it could be useful to use deploy functions directly. It makes it possible to later on support having another plugins around this (for example Boot).
AWS TransferManager will upload big files asynchronously in multiple parts. It also supports upload progress. See more from here: http://docs.aws.amazon.com/AmazonS3/latest/dev/HLuploadFileJava.html
I'm not sure whether this is me misunderstanding things (it may well be), but I was expecting that if I had production and test stages defined in my project.clj
, this would create a single API with two different stages. But what I see instead are two different APIs (with the same name). Am I misunderstanding?
To make this concrete, here is the relevant section of my project.clj
:
:lambda {"test" [{:api-gateway {:name "RotaApi"}
:handler "rota-api.core.MyLambdaFn"
:memory-size 512
:timeout 60
:function-name "rota-api-test"}]
"production" [{:api-gateway {:name "RotaApi"}
:handler "rota-api.core.MyLambdaFn"
:memory-size 512
:timeout 60
:function-name "rota-api"}]}
Running lein lambda install test
gives me:
Setting up API Gateway with api name RotaApi
Creating role api-gateway-role-saug2l89q6 with policy api-gateway-role-policy-saug2l89q6 and statements {:Version 2012-10-17, :Statement [{:Effect Allow, :Action [lambda:InvokeFunction], :Resource [arn:aws:lambda:eu-west-1:221985399864:function:rota-api-test]}]}
Creating integration with role-arn arn:aws:iam::221985399864:role/api-gateway-role-saug2l89q6
Deployed to https://saug2l89q6.execute-api.eu-west-1.amazonaws.com/test
And then lein lambda install production
gives me:
Setting up API Gateway with api name RotaApi
Creating role api-gateway-role-6od4rpb94g with policy api-gateway-role-policy-6od4rpb94g and statements {:Version 2012-10-17, :Statement [{:Effect Allow, :Action [lambda:InvokeFunction], :Resource [arn:aws:lambda:eu-west-1:221985399864:function:rota-api]}]}
Creating integration with role-arn arn:aws:iam::221985399864:role/api-gateway-role-6od4rpb94g
Deployed to https://6od4rpb94g.execute-api.eu-west-1.amazonaws.com/production
Sure enough, when I look in the API Gateway web console, I can see that I have two APIs, both called "RotaApi".
Is this intended?
I've spent the last few weeks implementing some lambda jobs and have written boot tasks to help with the deploy.
I wanted to open source the tasks, but rather than create a separate repository it would be better if it lived in this project, especially since you've taken the trouble to split out common and leiningen code. The repository might need to be renamed though!
I'm happy to do this, or if you'd prefer to do it yourself then that's fine too :) The offer is there!
When I'm running lein lambda install dev
, the process fails the first time during role creation with following error message java.lang.IllegalArgumentException: No matching field found: getRole for class clojure.lang.PersistentArrayMap
. On the second try it works, albeit with a warning message: Note! Role salvador-dev-role already exists.
Complete log:
➜ salvador git:(master) ✗ lein lambda install dev
Compiling salvador.core
Compiling salvador.handler
Created /Users/lars/Documents/salvador/target/salvador-0.1.0-SNAPSHOT.jar
Created /Users/lars/Documents/salvador/target/server.jar
Creating role salvador-dev-role with policy salvador-dev-policy
java.lang.IllegalArgumentException: No matching field found: getRole for class clojure.lang.PersistentArrayMap
at clojure.lang.Reflector.getInstanceField (Reflector.java:271)
clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:315)
leiningen.lambda$create_role_and_policy.invokeStatic (lambda.clj:72)
leiningen.lambda$create_role_and_policy.invoke (lambda.clj:58)
leiningen.lambda$install_lambda.invokeStatic (lambda.clj:126)
leiningen.lambda$install_lambda.invoke (lambda.clj:121)
leiningen.lambda$lambda.invokeStatic (lambda.clj:140)
leiningen.lambda$lambda.doInvoke (lambda.clj:137)
clojure.lang.RestFn.invoke (RestFn.java:439)
clojure.lang.Var.invoke (Var.java:388)
clojure.lang.AFn.applyToHelper (AFn.java:160)
clojure.lang.Var.applyTo (Var.java:700)
clojure.core$apply.invokeStatic (core.clj:648)
clojure.core$apply.invoke (core.clj:641)
leiningen.core.main$partial_task$fn__5829.doInvoke (main.clj:272)
clojure.lang.RestFn.applyTo (RestFn.java:139)
clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.core$apply.invokeStatic (core.clj:648)
clojure.core$apply.invoke (core.clj:641)
leiningen.core.main$apply_task.invokeStatic (main.clj:322)
leiningen.core.main$apply_task.invoke (main.clj:308)
lein_environ.plugin$write_env_to_file.invokeStatic (plugin.clj:11)
lein_environ.plugin$write_env_to_file.invoke (plugin.clj:9)
clojure.lang.Var.invoke (Var.java:394)
clojure.lang.AFn.applyToHelper (AFn.java:165)
clojure.lang.Var.applyTo (Var.java:700)
clojure.core$apply.invokeStatic (core.clj:648)
clojure.core$apply.invoke (core.clj:641)
robert.hooke$compose_hooks$fn__11923.doInvoke (hooke.clj:40)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.core$apply.invokeStatic (core.clj:646)
clojure.core$apply.invoke (core.clj:641)
robert.hooke$run_hooks.invokeStatic (hooke.clj:46)
robert.hooke$run_hooks.invoke (hooke.clj:45)
robert.hooke$prepare_for_hooks$fn__11928$fn__11929.doInvoke (hooke.clj:54)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
clojure.lang.RestFn.invoke (RestFn.java:436)
leiningen.core.main$resolve_and_apply.invokeStatic (main.clj:328)
leiningen.core.main$resolve_and_apply.invoke (main.clj:324)
leiningen.core.main$_main$fn__5895.invoke (main.clj:401)
leiningen.core.main$_main.invokeStatic (main.clj:394)
leiningen.core.main$_main.doInvoke (main.clj:391)
clojure.lang.RestFn.invoke (RestFn.java:436)
clojure.lang.Var.invoke (Var.java:388)
clojure.lang.AFn.applyToHelper (AFn.java:160)
clojure.lang.Var.applyTo (Var.java:700)
clojure.core$apply.invokeStatic (core.clj:646)
clojure.main$main_opt.invokeStatic (main.clj:314)
clojure.main$main_opt.invoke (main.clj:310)
clojure.main$main.invokeStatic (main.clj:421)
clojure.main$main.doInvoke (main.clj:384)
clojure.lang.RestFn.invoke (RestFn.java:482)
clojure.lang.Var.invoke (Var.java:401)
clojure.lang.AFn.applyToHelper (AFn.java:171)
clojure.lang.Var.applyTo (Var.java:700)
clojure.main.main (main.java:37)
➜ salvador git:(master) ✗ lein lambda install dev
Compiling salvador.core
Compiling salvador.handler
Created /Users/lars/Documents/salvador/target/salvador-0.1.0-SNAPSHOT.jar
Created /Users/lars/Documents/salvador/target/server.jar
Creating role salvador-dev-role with policy salvador-dev-policy
Note! Role salvador-dev-role already exists.
Installing to region us-east-1
leinrepo already exists. Skipping creation.
Uploading code to S3 bucket leinrepo with name salvador-dev.jar
Creating Lambda function salvador-dev to region us-east-1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.