File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717 run : ./gradlew build
1818 - name : Build demo with Gradle
1919 run : ./gradlew :demo:packageLambda
20+ - name : Invoke demo function locally
21+ run : ./gradlew :demo:localInvoke
Original file line number Diff line number Diff line change @@ -41,3 +41,22 @@ task buildDocker(type: Exec) {
4141 dependsOn classes
4242 commandLine ' ./buildDocker.sh'
4343}
44+
45+ task localInvoke {
46+ doLast {
47+ def file = new File (getTemporaryDir(), " out.json" )
48+ def event = ' {"message": "hello world"}'
49+ def command = " echo '${ event} ' | sam local invoke --event - > ${ file} "
50+ println " Running command: ${ command} "
51+ exec {
52+ executable ' bash'
53+ args ' -c' , command
54+ }
55+ def expectedOutput = ' {"message":"Received message: hello world"}'
56+ def actualOutput = file. text. trim()
57+ println actualOutput
58+ if (! expectedOutput. equals(actualOutput)) {
59+ throw new RuntimeException (" Expected output:\n\t ${ expectedOutput} \n Actual output:\n\t ${ actualOutput} " )
60+ }
61+ }
62+ }
Original file line number Diff line number Diff line change 1+ Transform : AWS::Serverless-2016-10-31
2+ Resources :
3+ DemoFunction :
4+ Type : AWS::Serverless::Function
5+ Properties :
6+ CodeUri : build/distributions/demo.zip # generated by ../gradlew :demo:packageLambda
7+ Handler : " " # handler is built into the runtime, value is not used
8+ Runtime : provided
You can’t perform that action at this time.
0 commit comments