├── .gitignore ├── LICENSE ├── README.md ├── aws-lambda-java-runtime ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── io │ │ │ └── redskap │ │ │ └── lambda │ │ │ └── runtime │ │ │ ├── LambdaRuntime.java │ │ │ ├── RequestHandlerRegistration.java │ │ │ ├── api │ │ │ ├── LambdaRuntimeHttpClient.java │ │ │ └── RuntimeInvocationHeaders.java │ │ │ ├── exception │ │ │ ├── InitializationException.java │ │ │ └── InvalidRequestHandlerRegistrationException.java │ │ │ ├── http │ │ │ ├── HttpClient.java │ │ │ ├── HttpHeaders.java │ │ │ └── HttpResponse.java │ │ │ ├── internal │ │ │ ├── ContextImpl.java │ │ │ ├── HandlerRegistrationResolver.java │ │ │ └── RequestHandlerInvoker.java │ │ │ ├── logging │ │ │ ├── LambdaLoggerHolder.java │ │ │ └── LambdaLoggerImpl.java │ │ │ ├── util │ │ │ ├── EnvironmentVariableResolver.java │ │ │ ├── JsonMapper.java │ │ │ └── ReservedEnvironmentVariables.java │ │ │ └── validation │ │ │ └── RequestHandlerRegistrationValidator.java │ └── resources │ │ └── META-INF │ │ └── native-image │ │ └── io.redskap │ │ └── aws-lambda-java-runtime │ │ ├── native-image.properties │ │ └── reflect-config.json │ └── test │ └── java │ └── io │ └── redskap │ └── lambda │ └── runtime │ ├── internal │ └── HandlerRegistrationResolverTest.java │ └── validation │ └── RequestHandlerRegistrationValidatorTest.java ├── build.gradle ├── docs ├── 404.html ├── assets │ ├── css │ │ └── 0.styles.3975cf68.css │ ├── img │ │ └── search.83621669.svg │ └── js │ │ ├── 2.3936b50a.js │ │ ├── 3.597e5726.js │ │ ├── 4.09ee8a39.js │ │ ├── 5.c661e667.js │ │ ├── 6.aa86b854.js │ │ ├── 7.9d661306.js │ │ ├── 8.3277f56e.js │ │ ├── 9.a78832c6.js │ │ └── app.810a9c82.js ├── changelog │ └── index.html ├── index.html └── troubleshooting │ └── index.html ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── samples ├── aws-lambda-java-dynamodb-native │ ├── .dockerignore │ ├── .gitignore │ ├── Dockerfile │ ├── bootstrap │ ├── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ │ └── main │ │ ├── java │ │ └── io │ │ │ └── redskap │ │ │ └── lambda │ │ │ └── runtime │ │ │ └── sample │ │ │ ├── NativeDynamoDBApp.java │ │ │ ├── TestRequest.java │ │ │ └── TestRequestHandler.java │ │ └── resources │ │ └── META-INF │ │ └── native-image │ │ └── io.redskap │ │ └── aws-lambda-java-dynamodb-native │ │ ├── native-image.properties │ │ ├── proxy-config.json │ │ ├── reflect-config.json │ │ └── resource-config.json └── aws-lambda-java-native │ ├── .dockerignore │ ├── .gitignore │ ├── Dockerfile │ ├── bootstrap │ ├── build.gradle │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ └── main │ └── java │ └── io │ └── redskap │ └── lambda │ └── runtime │ └── sample │ ├── APIGatewayRequestHandler.java │ ├── IdentityRequestHandler.java │ └── NativeApp.java ├── settings.gradle └── src-docs ├── .npmignore ├── package-lock.json ├── package.json └── src ├── .vuepress ├── config.js ├── enhanceApp.js └── styles │ ├── index.styl │ └── palette.styl ├── changelog └── README.md ├── index.md └── troubleshooting └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | 3 | .gradle 4 | .gradle/ 5 | .idea/ 6 | build/ 7 | !gradle/wrapper/gradle-wrapper.jar 8 | !**/src/main/**/build/ 9 | !**/src/test/**/build/ 10 | 11 | ### STS ### 12 | .apt_generated 13 | .classpath 14 | .factorypath 15 | .project 16 | .settings 17 | .springBeans 18 | .sts4-cache 19 | bin/ 20 | !**/src/main/**/bin/ 21 | !**/src/test/**/bin/ 22 | 23 | ### IntelliJ IDEA ### 24 | .idea 25 | *.iws 26 | *.iml 27 | *.ipr 28 | out/ 29 | !**/src/main/**/out/ 30 | !**/src/test/**/out/ 31 | 32 | ### NetBeans ### 33 | /nbproject/private/ 34 | /nbbuild/ 35 | /dist/ 36 | /nbdist/ 37 | /.nb-gradle/ 38 | 39 | ### VS Code ### 40 | .vscode/ 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AWS Lambda Java Runtime 2 | The library has been created to have a production ready 3 | implementation of the [AWS Lambda Runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html) in Java, and to use it as 4 | a foundation for creating GraalVM native images. 5 | 6 | [The corresponding article can be found on my blog](https://arnoldgalovics.com/tackling-java-cold-startup-times-on-aws-lambda-with-graalvm/). 7 | 8 | The full documentation can be found [here](https://redskap.github.io/aws-lambda-java-runtime/). 9 | 10 | # Samples 11 | There are 2 sample applications available at the moment: 12 | * Simple lambda function with returning the request body in the response (samples/aws-lambda-java-native) 13 | * Lambda function with writing into DynamoDB (samples/aws-lambda-java-dynamodb-native) 14 | 15 | # Building the runtime 16 | ```bash 17 | $ ./gradlew clean build 18 | ``` 19 | 20 | # License 21 | ```text 22 | Licensed under the Apache License, Version 2.0 (the "License"); 23 | you may not use this file except in compliance with the License. 24 | You may obtain a copy of the License at 25 | 26 | http://www.apache.org/licenses/LICENSE-2.0 27 | 28 | Unless required by applicable law or agreed to in writing, software 29 | distributed under the License is distributed on an "AS IS" BASIS, 30 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 31 | See the License for the specific language governing permissions and 32 | limitations under the License. 33 | ``` 34 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | !**/src/main/**/build/ 5 | !**/src/test/**/build/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | bin/ 16 | !**/src/main/**/bin/ 17 | !**/src/test/**/bin/ 18 | 19 | ### IntelliJ IDEA ### 20 | .idea 21 | *.iws 22 | *.iml 23 | *.ipr 24 | out/ 25 | !**/src/main/**/out/ 26 | !**/src/test/**/out/ 27 | 28 | ### NetBeans ### 29 | /nbproject/private/ 30 | /nbbuild/ 31 | /dist/ 32 | /nbdist/ 33 | /.nb-gradle/ 34 | 35 | ### VS Code ### 36 | .vscode/ 37 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'maven' 4 | } 5 | 6 | group = 'io.redskap' 7 | version = '0.0.2-SNAPSHOT' 8 | sourceCompatibility = '11' 9 | 10 | repositories { 11 | mavenCentral() 12 | } 13 | 14 | dependencies { 15 | api 'com.google.code.gson:gson:2.8.6' 16 | api 'com.amazonaws:aws-lambda-java-core:1.2.1' 17 | api 'com.amazonaws:aws-lambda-java-events:3.8.0' 18 | 19 | testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1' 20 | testImplementation 'org.assertj:assertj-core:3.19.0' 21 | testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1' 22 | } 23 | 24 | test { 25 | useJUnitPlatform() 26 | } 27 | 28 | // 29 | apply plugin: 'signing' 30 | 31 | task javadocJar(type: Jar) { 32 | archiveClassifier = 'javadoc' 33 | from javadoc 34 | } 35 | 36 | task sourcesJar(type: Jar) { 37 | archiveClassifier = 'sources' 38 | from sourceSets.main.allSource 39 | } 40 | 41 | artifacts { 42 | archives javadocJar, sourcesJar 43 | } 44 | 45 | if (project.hasProperty('signing.keyId')) { 46 | signing { 47 | sign configurations.archives 48 | } 49 | } 50 | 51 | if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) { 52 | uploadArchives { 53 | repositories { 54 | mavenDeployer { 55 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 56 | 57 | repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { 58 | authentication(userName: ossrhUsername, password: ossrhPassword) 59 | } 60 | 61 | snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { 62 | authentication(userName: ossrhUsername, password: ossrhPassword) 63 | } 64 | 65 | pom.project { 66 | name 'AWS Lambda Java Runtime' 67 | packaging 'jar' 68 | description 'AWS Lambda custom runtime in Java' 69 | url 'https://github.com/redskap/aws-lambda-java-runtime' 70 | 71 | scm { 72 | connection 'scm:git:git://github.com/redskap/aws-lambda-java-runtime.git' 73 | developerConnection 'scm:git:ssh://github.com:redskap/aws-lambda-java-runtime.git' 74 | url 'https://github.com/redskap/aws-lambda-java-runtime' 75 | } 76 | 77 | licenses { 78 | license { 79 | name 'The Apache License, Version 2.0' 80 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 81 | } 82 | } 83 | 84 | developers { 85 | developer { 86 | id 'galovics' 87 | name 'Arnold Galovics' 88 | email 'info@arnoldgalovics.com' 89 | } 90 | } 91 | } 92 | } 93 | } 94 | } 95 | } 96 | // -------------------------------------------------------------------------------- /aws-lambda-java-runtime/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redskap/aws-lambda-java-runtime/27bc28a29d6384d1feb6f524697a25ac11a293b1/aws-lambda-java-runtime/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /aws-lambda-java-runtime/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'aws-lambda-java-runtime' 2 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/LambdaRuntime.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime; 2 | 3 | import io.redskap.lambda.runtime.api.LambdaRuntimeHttpClient; 4 | import io.redskap.lambda.runtime.api.RuntimeInvocationHeaders; 5 | import io.redskap.lambda.runtime.exception.InitializationException; 6 | import io.redskap.lambda.runtime.http.HttpResponse; 7 | import io.redskap.lambda.runtime.internal.HandlerRegistrationResolver; 8 | import io.redskap.lambda.runtime.internal.RequestHandlerInvoker; 9 | import io.redskap.lambda.runtime.util.EnvironmentVariableResolver; 10 | import io.redskap.lambda.runtime.util.ReservedEnvironmentVariables; 11 | import io.redskap.lambda.runtime.validation.RequestHandlerRegistrationValidator; 12 | 13 | import java.util.Collection; 14 | 15 | public class LambdaRuntime { 16 | private final Collection> handlerRegistrations; 17 | private final RequestHandlerRegistrationValidator registrationValidator; 18 | private final HandlerRegistrationResolver handlerRegistrationResolver; 19 | 20 | public LambdaRuntime(Collection> handlerRegistrations) { 21 | this(handlerRegistrations, new RequestHandlerRegistrationValidator(), new HandlerRegistrationResolver()); 22 | } 23 | 24 | public LambdaRuntime(Collection> handlerRegistrations, RequestHandlerRegistrationValidator registrationValidator, 25 | HandlerRegistrationResolver handlerRegistrationResolver) { 26 | this.handlerRegistrations = handlerRegistrations; 27 | this.registrationValidator = registrationValidator; 28 | this.handlerRegistrationResolver = handlerRegistrationResolver; 29 | } 30 | 31 | public void run() { 32 | String runtimeApi = EnvironmentVariableResolver.resolve(ReservedEnvironmentVariables.AWS_LAMBDA_RUNTIME_API); 33 | LambdaRuntimeHttpClient runtimeHttpClient = new LambdaRuntimeHttpClient(runtimeApi); 34 | try { 35 | String handlerConfigurationValue = EnvironmentVariableResolver.resolve(ReservedEnvironmentVariables.HANDLER); 36 | RequestHandlerRegistration handlerRegistration = handlerRegistrationResolver.resolve(handlerConfigurationValue, handlerRegistrations); 37 | registrationValidator.validate(handlerRegistration); 38 | while (true) { 39 | HttpResponse event = runtimeHttpClient.nextInvocation(); 40 | String requestId = event.getHeaders().getSingleValueHeader(RuntimeInvocationHeaders.LAMBDA_RUNTIME_AWS_REQUEST_ID); 41 | try { 42 | String response = RequestHandlerInvoker.invokeHandler(event, handlerRegistration); 43 | runtimeHttpClient.invocationResponse(requestId, response); 44 | } catch (Exception e) { 45 | runtimeHttpClient.invocationError(requestId); 46 | e.printStackTrace(); 47 | } 48 | } 49 | } catch (InitializationException e) { 50 | e.printStackTrace(); 51 | runtimeHttpClient.initializationError(e.getMessage()); 52 | } catch (Exception e) { 53 | e.printStackTrace(); 54 | runtimeHttpClient.initializationError("Initialization Error"); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/RequestHandlerRegistration.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime; 2 | 3 | import com.amazonaws.services.lambda.runtime.RequestHandler; 4 | 5 | public class RequestHandlerRegistration { 6 | private final RequestHandler handler; 7 | private final Class requestType; 8 | private final Class responseType; 9 | 10 | public RequestHandlerRegistration(RequestHandler handler, Class requestType, Class responseType) { 11 | this.handler = handler; 12 | this.requestType = requestType; 13 | this.responseType = responseType; 14 | } 15 | 16 | public RequestHandler getHandler() { 17 | return handler; 18 | } 19 | 20 | public Class getRequestType() { 21 | return requestType; 22 | } 23 | 24 | public Class getResponseType() { 25 | return responseType; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/api/LambdaRuntimeHttpClient.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.api; 2 | 3 | import io.redskap.lambda.runtime.http.HttpClient; 4 | import io.redskap.lambda.runtime.http.HttpResponse; 5 | 6 | import java.text.MessageFormat; 7 | 8 | public class LambdaRuntimeHttpClient { 9 | private static final String LAMBDA_VERSION_DATE = "2018-06-01"; 10 | private static final String LAMBDA_NEXT_INVOCATION_TEMPLATE = "http://{0}/{1}/runtime/invocation/next"; 11 | private static final String LAMBDA_INVOCATION_RESPONSE_URL_TEMPLATE = "http://{0}/{1}/runtime/invocation/{2}/response"; 12 | private static final String LAMBDA_INVOCATION_ERROR_URL_TEMPLATE = "http://{0}/{1}/runtime/invocation/{2}/error"; 13 | private static final String LAMBDA_INIT_ERROR_URL_TEMPLATE = "http://{0}/{1}/runtime/init/error"; 14 | 15 | private static final String ERROR_RESPONSE_TEMPLATE = "'{'" + 16 | "\"errorMessage\": \"{0}\"," + 17 | "\"errorType\": \"{1}\"" + 18 | "'}'"; 19 | 20 | private final HttpClient httpClient; 21 | 22 | private final String runtimeApi; 23 | private final String nextInvocationUrl; 24 | 25 | public LambdaRuntimeHttpClient(String runtimeApi) { 26 | this.httpClient = new HttpClient(); 27 | this.runtimeApi = runtimeApi; 28 | this.nextInvocationUrl = MessageFormat.format(LAMBDA_NEXT_INVOCATION_TEMPLATE, this.runtimeApi, LAMBDA_VERSION_DATE); 29 | } 30 | 31 | public HttpResponse nextInvocation() { 32 | return httpClient.get(nextInvocationUrl); 33 | } 34 | 35 | public HttpResponse invocationResponse(String requestId, String body) { 36 | String invocationResponseUrl = MessageFormat.format(LAMBDA_INVOCATION_RESPONSE_URL_TEMPLATE, runtimeApi, LAMBDA_VERSION_DATE, requestId); 37 | return httpClient.post(invocationResponseUrl, body); 38 | } 39 | 40 | public HttpResponse invocationError(String requestId) { 41 | String invocationErrorUrl = MessageFormat.format(LAMBDA_INVOCATION_ERROR_URL_TEMPLATE, runtimeApi, LAMBDA_VERSION_DATE, requestId); 42 | String error = MessageFormat.format(ERROR_RESPONSE_TEMPLATE, "Invocation Error", "RuntimeException"); 43 | return httpClient.post(invocationErrorUrl, error); 44 | } 45 | 46 | public HttpResponse initializationError(String errorMessage) { 47 | String initErrorUrl = MessageFormat.format(LAMBDA_INIT_ERROR_URL_TEMPLATE, runtimeApi, LAMBDA_VERSION_DATE); 48 | String error = MessageFormat.format(ERROR_RESPONSE_TEMPLATE, errorMessage, "InitializationException"); 49 | return httpClient.post(initErrorUrl, error); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/api/RuntimeInvocationHeaders.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.api; 2 | 3 | public interface RuntimeInvocationHeaders { 4 | String LAMBDA_RUNTIME_AWS_REQUEST_ID = "Lambda-Runtime-Aws-Request-Id"; 5 | String LAMBDA_RUNTIME_DEADLINE_MS = "Lambda-Runtime-Deadline-Ms"; 6 | String LAMBDA_RUNTIME_INVOKED_FUNCTION_ARN = "Lambda-Runtime-Invoked-Function-Arn"; 7 | String LAMBDA_RUNTIME_TRACE_ID = "Lambda-Runtime-Trace-Id"; 8 | String LAMBDA_RUNTIME_CLIENT_CONTEXT = "Lambda-Runtime-Client-Context"; 9 | String LAMBDA_RUNTIME_COGNITO_IDENTITY = "Lambda-Runtime-Cognito-Identity"; 10 | } 11 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/exception/InitializationException.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.exception; 2 | 3 | public class InitializationException extends RuntimeException { 4 | public InitializationException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/exception/InvalidRequestHandlerRegistrationException.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.exception; 2 | 3 | public class InvalidRequestHandlerRegistrationException extends InitializationException { 4 | public InvalidRequestHandlerRegistrationException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/http/HttpClient.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.http; 2 | 3 | import java.io.*; 4 | import java.net.HttpURLConnection; 5 | import java.net.URL; 6 | import java.nio.charset.StandardCharsets; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | public class HttpClient { 12 | 13 | public HttpResponse get(String urlString) { 14 | HttpResponse output; 15 | try { 16 | URL url = new URL(urlString); 17 | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 18 | conn.setRequestMethod("GET"); 19 | output = parseResponse(conn); 20 | } catch (IOException e) { 21 | throw new RuntimeException("Error while sending GET request", e); 22 | } 23 | 24 | return output; 25 | } 26 | 27 | public HttpResponse post(String urlString, String body) { 28 | HttpResponse output; 29 | try { 30 | URL url = new URL(urlString); 31 | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 32 | conn.setRequestMethod("POST"); 33 | conn.setDoOutput(true); 34 | try (OutputStream os = conn.getOutputStream(); 35 | OutputStreamWriter osw = new OutputStreamWriter(os, StandardCharsets.UTF_8)) { 36 | osw.write(body); 37 | osw.flush(); 38 | } 39 | conn.connect(); 40 | output = parseResponse(conn); 41 | } catch (IOException e) { 42 | throw new RuntimeException("Error while sending POST request", e); 43 | } 44 | 45 | return output; 46 | } 47 | 48 | private HttpResponse parseResponse(HttpURLConnection conn) throws IOException { 49 | HashMap> headersMap = new HashMap<>(); 50 | for (Map.Entry> entry : conn.getHeaderFields().entrySet()) { 51 | headersMap.put(entry.getKey(), entry.getValue()); 52 | } 53 | BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); 54 | StringBuilder result = new StringBuilder(); 55 | String line; 56 | while ((line = rd.readLine()) != null) { 57 | result.append(line); 58 | } 59 | rd.close(); 60 | return new HttpResponse(conn.getResponseCode(), new HttpHeaders(headersMap), result.toString()); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/http/HttpHeaders.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.http; 2 | 3 | import java.util.Collections; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | public class HttpHeaders { 8 | private Map> headerMap; 9 | 10 | public HttpHeaders(Map> headerMap) { 11 | this.headerMap = headerMap; 12 | } 13 | 14 | public Map> getHeaderMap() { 15 | return Collections.unmodifiableMap(headerMap); 16 | } 17 | 18 | public String getSingleValueHeader(String key) { 19 | List headerValues = headerMap.get(key); 20 | if (headerValues != null && headerValues.size() > 0) { 21 | return headerValues.iterator().next(); 22 | } 23 | return null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/http/HttpResponse.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.http; 2 | 3 | public class HttpResponse { 4 | private int statusCode; 5 | private HttpHeaders headers; 6 | private String body; 7 | 8 | public HttpResponse(int statusCode, HttpHeaders headers, String body) { 9 | this.statusCode = statusCode; 10 | this.headers = headers; 11 | this.body = body; 12 | } 13 | 14 | public int getStatusCode() { 15 | return statusCode; 16 | } 17 | 18 | public HttpHeaders getHeaders() { 19 | return headers; 20 | } 21 | 22 | public String getBody() { 23 | return body; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/internal/ContextImpl.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.internal; 2 | 3 | import com.amazonaws.services.lambda.runtime.ClientContext; 4 | import com.amazonaws.services.lambda.runtime.CognitoIdentity; 5 | import com.amazonaws.services.lambda.runtime.Context; 6 | import com.amazonaws.services.lambda.runtime.LambdaLogger; 7 | import io.redskap.lambda.runtime.api.RuntimeInvocationHeaders; 8 | import io.redskap.lambda.runtime.http.HttpHeaders; 9 | import io.redskap.lambda.runtime.logging.LambdaLoggerHolder; 10 | import io.redskap.lambda.runtime.util.EnvironmentVariableResolver; 11 | import io.redskap.lambda.runtime.util.ReservedEnvironmentVariables; 12 | 13 | import java.util.Calendar; 14 | 15 | public class ContextImpl implements Context { 16 | private HttpHeaders headers; 17 | 18 | public ContextImpl(HttpHeaders headers) { 19 | this.headers = headers; 20 | } 21 | 22 | @Override 23 | public String getAwsRequestId() { 24 | return headers.getSingleValueHeader(RuntimeInvocationHeaders.LAMBDA_RUNTIME_AWS_REQUEST_ID); 25 | } 26 | 27 | @Override 28 | public String getLogGroupName() { 29 | return EnvironmentVariableResolver.resolve(ReservedEnvironmentVariables.AWS_LAMBDA_LOG_GROUP_NAME); 30 | } 31 | 32 | @Override 33 | public String getLogStreamName() { 34 | return EnvironmentVariableResolver.resolve(ReservedEnvironmentVariables.AWS_LAMBDA_LOG_STREAM_NAME); 35 | } 36 | 37 | @Override 38 | public String getFunctionName() { 39 | return EnvironmentVariableResolver.resolve(ReservedEnvironmentVariables.AWS_LAMBDA_FUNCTION_NAME); 40 | } 41 | 42 | @Override 43 | public String getFunctionVersion() { 44 | return EnvironmentVariableResolver.resolve(ReservedEnvironmentVariables.AWS_LAMBDA_FUNCTION_VERSION); 45 | } 46 | 47 | @Override 48 | public String getInvokedFunctionArn() { 49 | return headers.getSingleValueHeader(RuntimeInvocationHeaders.LAMBDA_RUNTIME_INVOKED_FUNCTION_ARN); 50 | } 51 | 52 | @Override 53 | public CognitoIdentity getIdentity() { 54 | // TODO 55 | throw new UnsupportedOperationException("Not implemented"); 56 | } 57 | 58 | @Override 59 | public ClientContext getClientContext() { 60 | // TODO 61 | throw new UnsupportedOperationException("Not implemented"); 62 | } 63 | 64 | @Override 65 | public int getRemainingTimeInMillis() { 66 | String deadlineMsStr = headers.getSingleValueHeader(RuntimeInvocationHeaders.LAMBDA_RUNTIME_DEADLINE_MS); 67 | try { 68 | if (deadlineMsStr != null) { 69 | long deadlineMs = Long.parseLong(deadlineMsStr); 70 | long currentMs = currentTime(); 71 | long remainingMs = deadlineMs - currentMs; 72 | return (int) remainingMs; 73 | } 74 | } catch (NumberFormatException e) { 75 | } 76 | return 0; 77 | } 78 | 79 | @Override 80 | public int getMemoryLimitInMB() { 81 | String memoryLimit = EnvironmentVariableResolver.resolve(ReservedEnvironmentVariables.AWS_LAMBDA_FUNCTION_MEMORY_SIZE); 82 | if (memoryLimit != null) { 83 | try { 84 | return Integer.parseInt(memoryLimit); 85 | } catch (NumberFormatException e) { 86 | } 87 | } 88 | return 0; 89 | } 90 | 91 | @Override 92 | public LambdaLogger getLogger() { 93 | return LambdaLoggerHolder.getLambdaLogger(); 94 | } 95 | 96 | private long currentTime() { 97 | return Calendar.getInstance().getTimeInMillis(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/internal/HandlerRegistrationResolver.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.internal; 2 | 3 | import io.redskap.lambda.runtime.RequestHandlerRegistration; 4 | 5 | import java.util.Collection; 6 | 7 | public class HandlerRegistrationResolver { 8 | public RequestHandlerRegistration resolve(String handlerConfigurationValue, Collection> handlerRegistrations) { 9 | if (handlerConfigurationValue != null) { 10 | String handlerClassName = parseHandlerClassName(handlerConfigurationValue); 11 | if (handlerClassName != null) { 12 | for (RequestHandlerRegistration registration : handlerRegistrations) { 13 | if (handlerClassName.equals(registration.getHandler().getClass().getName())) { 14 | return registration; 15 | } 16 | } 17 | } 18 | } 19 | return null; 20 | } 21 | 22 | private String parseHandlerClassName(String handler) { 23 | String[] splitHandler = handler.split("::"); 24 | if (splitHandler.length > 0) { 25 | return splitHandler[0]; 26 | } 27 | return null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/internal/RequestHandlerInvoker.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.internal; 2 | 3 | import com.amazonaws.services.lambda.runtime.RequestHandler; 4 | import io.redskap.lambda.runtime.RequestHandlerRegistration; 5 | import io.redskap.lambda.runtime.http.HttpResponse; 6 | import io.redskap.lambda.runtime.util.JsonMapper; 7 | 8 | public class RequestHandlerInvoker { 9 | public static String invokeHandler(HttpResponse event, RequestHandlerRegistration registration) { 10 | return internalInvokeHandler(event, registration.getHandler(), registration.getRequestType(), registration.getResponseType()); 11 | } 12 | 13 | private static String internalInvokeHandler(HttpResponse event, RequestHandler handler, Class requestType, Class responseType) { 14 | I request; 15 | if (!String.class.equals(requestType)) { 16 | request = JsonMapper.fromJson(event.getBody(), requestType); 17 | } else { 18 | request = (I) event.getBody(); 19 | } 20 | O response = handler.handleRequest(request, new ContextImpl(event.getHeaders())); 21 | if (response != null) { 22 | if (!String.class.equals(responseType)) { 23 | return JsonMapper.toJson(response); 24 | } else { 25 | return response.toString(); 26 | } 27 | } else { 28 | return ""; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/logging/LambdaLoggerHolder.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.logging; 2 | 3 | import com.amazonaws.services.lambda.runtime.LambdaLogger; 4 | 5 | public class LambdaLoggerHolder { 6 | private static final LambdaLogger LAMBDA_LOGGER = new LambdaLoggerImpl(); 7 | 8 | public static LambdaLogger getLambdaLogger() { 9 | return LAMBDA_LOGGER; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/logging/LambdaLoggerImpl.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.logging; 2 | 3 | import com.amazonaws.services.lambda.runtime.LambdaLogger; 4 | 5 | import java.io.IOException; 6 | 7 | public class LambdaLoggerImpl implements LambdaLogger { 8 | @Override 9 | public void log(String message) { 10 | System.out.print(message); 11 | } 12 | 13 | @Override 14 | public void log(byte[] message) { 15 | try { 16 | System.out.write(message); 17 | } catch (IOException e) { 18 | throw new RuntimeException("Error while writing out the log", e); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/util/EnvironmentVariableResolver.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.util; 2 | 3 | public class EnvironmentVariableResolver { 4 | public static String resolve(String key) { 5 | return System.getenv(key); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/util/JsonMapper.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.util; 2 | 3 | import com.google.gson.Gson; 4 | 5 | public class JsonMapper { 6 | private static final Gson GSON = new Gson(); 7 | 8 | public static T fromJson(String json, Class type) { 9 | return GSON.fromJson(json, type); 10 | } 11 | 12 | public static String toJson(Object o) { 13 | return GSON.toJson(o); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/util/ReservedEnvironmentVariables.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.util; 2 | 3 | public interface ReservedEnvironmentVariables { 4 | String HANDLER = "_HANDLER"; 5 | String X_AMZN_TRACE_ID = "_X_AMZN_TRACE_ID"; 6 | String AWS_REGION = "AWS_REGION"; 7 | String AWS_EXECUTION_ENV = "AWS_EXECUTION_ENV"; 8 | String AWS_LAMBDA_FUNCTION_NAME = "AWS_LAMBDA_FUNCTION_NAME"; 9 | String AWS_LAMBDA_FUNCTION_MEMORY_SIZE = "AWS_LAMBDA_FUNCTION_MEMORY_SIZE"; 10 | String AWS_LAMBDA_FUNCTION_VERSION = "AWS_LAMBDA_FUNCTION_VERSION"; 11 | String AWS_LAMBDA_INITIALIZATION_TYPE = "AWS_LAMBDA_INITIALIZATION_TYPE"; 12 | String AWS_LAMBDA_LOG_GROUP_NAME = "AWS_LAMBDA_LOG_GROUP_NAME"; 13 | String AWS_LAMBDA_LOG_STREAM_NAME = "AWS_LAMBDA_LOG_STREAM_NAME"; 14 | String AWS_ACCESS_KEY_ID = "AWS_ACCESS_KEY_ID"; 15 | String AWS_SECRET_ACCESS_KEY = "AWS_SECRET_ACCESS_KEY"; 16 | String AWS_SESSION_TOKEN = "AWS_SESSION_TOKEN"; 17 | String AWS_LAMBDA_RUNTIME_API = "AWS_LAMBDA_RUNTIME_API"; 18 | String LAMBDA_TASK_ROOT = "LAMBDA_TASK_ROOT"; 19 | String LAMBDA_RUNTIME_DIR = "LAMBDA_RUNTIME_DIR"; 20 | String TZ = "TZ"; 21 | } 22 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/java/io/redskap/lambda/runtime/validation/RequestHandlerRegistrationValidator.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.validation; 2 | 3 | import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; 4 | import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; 5 | import io.redskap.lambda.runtime.RequestHandlerRegistration; 6 | import io.redskap.lambda.runtime.exception.InitializationException; 7 | import io.redskap.lambda.runtime.exception.InvalidRequestHandlerRegistrationException; 8 | 9 | import java.util.*; 10 | 11 | public class RequestHandlerRegistrationValidator { 12 | private static final Set> SUPPORTED_CLASSES = new HashSet<>(); 13 | 14 | static { 15 | SUPPORTED_CLASSES.add(String.class); 16 | SUPPORTED_CLASSES.add(APIGatewayProxyRequestEvent.class); 17 | SUPPORTED_CLASSES.add(APIGatewayProxyResponseEvent.class); 18 | } 19 | 20 | private final Collection> additionalClasses; 21 | 22 | public RequestHandlerRegistrationValidator() { 23 | this(Collections.emptyList()); 24 | } 25 | 26 | public RequestHandlerRegistrationValidator(Collection> additionalClasses) { 27 | this.additionalClasses = additionalClasses; 28 | } 29 | 30 | public void validate(RequestHandlerRegistration registration) { 31 | validateNotNull(registration); 32 | validateRegistrationTypes(registration); 33 | } 34 | 35 | private void validateNotNull(RequestHandlerRegistration registration) { 36 | if (registration == null) { 37 | throw new InitializationException("Handler is not found"); 38 | } 39 | } 40 | 41 | protected void validateRegistrationTypes(RequestHandlerRegistration registration) { 42 | Class requestType = registration.getRequestType(); 43 | if (!SUPPORTED_CLASSES.contains(requestType) && !additionalClasses.contains(requestType)) { 44 | throw new InvalidRequestHandlerRegistrationException("Request type " + requestType.getName() + " is not supported"); 45 | } 46 | Class responseType = registration.getResponseType(); 47 | if (!SUPPORTED_CLASSES.contains(responseType) && !additionalClasses.contains(responseType)) { 48 | throw new InvalidRequestHandlerRegistrationException("Response type " + responseType.getName() + " is not supported"); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/resources/META-INF/native-image/io.redskap/aws-lambda-java-runtime/native-image.properties: -------------------------------------------------------------------------------- 1 | Args = --no-fallback --enable-url-protocols=http -H:+InlineBeforeAnalysis \ 2 | --initialize-at-build-time=io.redskap.lambda.runtime.validation.RequestHandlerRegistrationValidator,\ 3 | io.redskap.lambda.runtime.logging.LambdaLoggerHolder -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/main/resources/META-INF/native-image/io.redskap/aws-lambda-java-runtime/reflect-config.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent", 4 | "allDeclaredFields": true, 5 | "allDeclaredConstructors": true, 6 | "allDeclaredMethods": true, 7 | "allDeclaredClasses" : true 8 | }, 9 | { 10 | "name": "com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent$ProxyRequestContext", 11 | "allDeclaredFields": true, 12 | "allDeclaredConstructors": true, 13 | "allDeclaredMethods": true, 14 | "allDeclaredClasses" : true 15 | }, 16 | { 17 | "name": "com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent$RequestIdentity", 18 | "allDeclaredFields": true, 19 | "allDeclaredConstructors": true, 20 | "allDeclaredMethods": true, 21 | "allDeclaredClasses" : true 22 | }, 23 | { 24 | "name": "com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent", 25 | "allDeclaredFields": true, 26 | "allDeclaredConstructors": true, 27 | "allDeclaredMethods": true, 28 | "allDeclaredClasses" : true 29 | } 30 | ] -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/test/java/io/redskap/lambda/runtime/internal/HandlerRegistrationResolverTest.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.internal; 2 | 3 | import com.amazonaws.services.lambda.runtime.Context; 4 | import com.amazonaws.services.lambda.runtime.RequestHandler; 5 | import io.redskap.lambda.runtime.RequestHandlerRegistration; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import java.util.Collection; 9 | 10 | import static java.util.Arrays.asList; 11 | import static org.assertj.core.api.Assertions.assertThat; 12 | 13 | class HandlerRegistrationResolverTest { 14 | private HandlerRegistrationResolver underTest = new HandlerRegistrationResolver(); 15 | 16 | @Test 17 | void testResolveShouldReturnNullWhenNullGiven() { 18 | // given 19 | RequestHandlerRegistration stringHandlerRegistration = new RequestHandlerRegistration<>(new StringRequestHandler(), String.class, String.class); 20 | RequestHandlerRegistration objectHandlerRegistration = new RequestHandlerRegistration<>(new ObjectRequestHandler(), Object.class, Object.class); 21 | Collection> handlerRegistrations = asList(stringHandlerRegistration, objectHandlerRegistration); 22 | // when 23 | RequestHandlerRegistration result = underTest.resolve(null, handlerRegistrations); 24 | // then 25 | assertThat(result).isNull(); 26 | } 27 | 28 | @Test 29 | void testResolveShouldReturnNullWhenEmptyStringGiven() { 30 | // given 31 | RequestHandlerRegistration stringHandlerRegistration = new RequestHandlerRegistration<>(new StringRequestHandler(), String.class, String.class); 32 | RequestHandlerRegistration objectHandlerRegistration = new RequestHandlerRegistration<>(new ObjectRequestHandler(), Object.class, Object.class); 33 | Collection> handlerRegistrations = asList(stringHandlerRegistration, objectHandlerRegistration); 34 | // when 35 | RequestHandlerRegistration result = underTest.resolve("", handlerRegistrations); 36 | // then 37 | assertThat(result).isNull(); 38 | } 39 | 40 | @Test 41 | void testResolveShouldReturnNullWhenOnlySimpleClassNameGiven() { 42 | // given 43 | RequestHandlerRegistration stringHandlerRegistration = new RequestHandlerRegistration<>(new StringRequestHandler(), String.class, String.class); 44 | RequestHandlerRegistration objectHandlerRegistration = new RequestHandlerRegistration<>(new ObjectRequestHandler(), Object.class, Object.class); 45 | Collection> handlerRegistrations = asList(stringHandlerRegistration, objectHandlerRegistration); 46 | // when 47 | RequestHandlerRegistration result = underTest.resolve("HandlerRegistrationResolverTest$ObjectRequestHandler", handlerRegistrations); 48 | // then 49 | assertThat(result).isNull(); 50 | } 51 | 52 | @Test 53 | void testResolveShouldReturnProperRegistrationWithOnlyFullyQualifiedClassName() { 54 | // given 55 | RequestHandlerRegistration stringHandlerRegistration = new RequestHandlerRegistration<>(new StringRequestHandler(), String.class, String.class); 56 | RequestHandlerRegistration objectHandlerRegistration = new RequestHandlerRegistration<>(new ObjectRequestHandler(), Object.class, Object.class); 57 | Collection> handlerRegistrations = asList(stringHandlerRegistration, objectHandlerRegistration); 58 | // when 59 | RequestHandlerRegistration result = underTest.resolve("io.redskap.lambda.runtime.internal.HandlerRegistrationResolverTest$ObjectRequestHandler", handlerRegistrations); 60 | // then 61 | assertThat(result).isEqualTo(objectHandlerRegistration); 62 | } 63 | 64 | @Test 65 | void testResolveShouldReturnProperRegistrationWithOnlyFullyQualifiedClassNameAndHandlerMethod() { 66 | // given 67 | RequestHandlerRegistration stringHandlerRegistration = new RequestHandlerRegistration<>(new StringRequestHandler(), String.class, String.class); 68 | RequestHandlerRegistration objectHandlerRegistration = new RequestHandlerRegistration<>(new ObjectRequestHandler(), Object.class, Object.class); 69 | Collection> handlerRegistrations = asList(stringHandlerRegistration, objectHandlerRegistration); 70 | // when 71 | RequestHandlerRegistration result = underTest.resolve("io.redskap.lambda.runtime.internal.HandlerRegistrationResolverTest$ObjectRequestHandler::handleRequest", handlerRegistrations); 72 | // then 73 | assertThat(result).isEqualTo(objectHandlerRegistration); 74 | } 75 | 76 | private static class StringRequestHandler implements RequestHandler { 77 | @Override 78 | public String handleRequest(String input, Context context) { 79 | return null; 80 | } 81 | } 82 | 83 | private static class ObjectRequestHandler implements RequestHandler { 84 | @Override 85 | public Object handleRequest(Object input, Context context) { 86 | return null; 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /aws-lambda-java-runtime/src/test/java/io/redskap/lambda/runtime/validation/RequestHandlerRegistrationValidatorTest.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.validation; 2 | 3 | import io.redskap.lambda.runtime.RequestHandlerRegistration; 4 | import io.redskap.lambda.runtime.exception.InitializationException; 5 | import org.junit.jupiter.api.Test; 6 | 7 | import java.util.Collections; 8 | 9 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 10 | import static org.junit.jupiter.api.Assertions.assertThrows; 11 | 12 | class RequestHandlerRegistrationValidatorTest { 13 | private final RequestHandlerRegistrationValidator underTest = new RequestHandlerRegistrationValidator(); 14 | 15 | @Test 16 | void testValidateShouldThrowExceptionWhenNullGiven() { 17 | // given 18 | RequestHandlerRegistration registration = null; 19 | // when & then 20 | assertThrows(InitializationException.class, () -> { 21 | underTest.validate(registration); 22 | }); 23 | } 24 | 25 | @Test 26 | void testValidateShouldThrowExceptionWhenUnsupportedRequestClassGiven() { 27 | // given 28 | RequestHandlerRegistration registration = new RequestHandlerRegistration<>((input, context) -> input, Object.class, Object.class); 29 | // when & then 30 | assertThrows(InitializationException.class, () -> { 31 | underTest.validate(registration); 32 | }); 33 | } 34 | 35 | @Test 36 | void testValidateShouldThrowExceptionWhenUnsupportedResponseClassGiven() { 37 | // given 38 | RequestHandlerRegistration registration = new RequestHandlerRegistration<>((input, context) -> input, String.class, Object.class); 39 | // when & then 40 | assertThrows(InitializationException.class, () -> { 41 | underTest.validate(registration); 42 | }); 43 | } 44 | 45 | @Test 46 | void testValidateShouldWorkWhenFrameworkSupportedClassGiven() { 47 | // given 48 | RequestHandlerRegistration registration = new RequestHandlerRegistration<>((input, context) -> input, String.class, String.class); 49 | // when & then 50 | assertDoesNotThrow(() -> underTest.validate(registration)); 51 | } 52 | 53 | 54 | @Test 55 | void testValidateShouldWorkWhenExtendedSupportedClassGiven() { 56 | // given 57 | RequestHandlerRegistrationValidator validator = new RequestHandlerRegistrationValidator(Collections.singleton(TestPojo.class)); 58 | RequestHandlerRegistration registration = new RequestHandlerRegistration<>((input, context) -> input, TestPojo.class, TestPojo.class); 59 | // when & then 60 | assertDoesNotThrow(() -> validator.validate(registration)); 61 | } 62 | 63 | private static class TestPojo { 64 | } 65 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redskap/aws-lambda-java-runtime/27bc28a29d6384d1feb6f524697a25ac11a293b1/build.gradle -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | AWS Lambda Java Runtime 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |

404

How did we get here?
19 | Take me home. 20 |
21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/assets/css/0.styles.3975cf68.css: -------------------------------------------------------------------------------- 1 | code[class*=language-],pre[class*=language-]{color:#ccc;background:none;font-family:Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#999}.token.punctuation{color:#ccc}.token.attr-name,.token.deleted,.token.namespace,.token.tag{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.function,.token.number{color:#f08d49}.token.class-name,.token.constant,.token.property,.token.symbol{color:#f8c555}.token.atrule,.token.builtin,.token.important,.token.keyword,.token.selector{color:#cc99cd}.token.attr-value,.token.char,.token.regex,.token.string,.token.variable{color:#7ec699}.token.entity,.token.operator,.token.url{color:#67cdcc}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green}.theme-default-content code{color:#476582;padding:.25rem .5rem;margin:0;font-size:.85em;background-color:rgba(27,31,35,.05);border-radius:3px}.theme-default-content code .token.deleted{color:#ec5975}.theme-default-content code .token.inserted{color:#3eaf7c}.theme-default-content pre,.theme-default-content pre[class*=language-]{line-height:1.4;padding:1.25rem 1.5rem;margin:.85rem 0;background-color:#282c34;border-radius:6px;overflow:auto}.theme-default-content pre[class*=language-] code,.theme-default-content pre code{color:#fff;padding:0;background-color:transparent;border-radius:0}div[class*=language-]{position:relative;background-color:#282c34;border-radius:6px}div[class*=language-] .highlight-lines{-webkit-user-select:none;user-select:none;padding-top:1.3rem;position:absolute;top:0;left:0;width:100%;line-height:1.4}div[class*=language-] .highlight-lines .highlighted{background-color:rgba(0,0,0,.66)}div[class*=language-] pre,div[class*=language-] pre[class*=language-]{background:transparent;position:relative;z-index:1}div[class*=language-]:before{position:absolute;z-index:3;top:.8em;right:1em;font-size:.75rem;color:hsla(0,0%,100%,.4)}div[class*=language-]:not(.line-numbers-mode) .line-numbers-wrapper{display:none}div[class*=language-].line-numbers-mode .highlight-lines .highlighted{position:relative}div[class*=language-].line-numbers-mode .highlight-lines .highlighted:before{content:" ";position:absolute;z-index:3;left:0;top:0;display:block;width:3.5rem;height:100%;background-color:rgba(0,0,0,.66)}div[class*=language-].line-numbers-mode pre{padding-left:4.5rem;vertical-align:middle}div[class*=language-].line-numbers-mode .line-numbers-wrapper{position:absolute;top:0;width:3.5rem;text-align:center;color:hsla(0,0%,100%,.3);padding:1.25rem 0;line-height:1.4}div[class*=language-].line-numbers-mode .line-numbers-wrapper br{-webkit-user-select:none;user-select:none}div[class*=language-].line-numbers-mode .line-numbers-wrapper .line-number{position:relative;z-index:4;-webkit-user-select:none;user-select:none;font-size:.85em}div[class*=language-].line-numbers-mode:after{content:"";position:absolute;z-index:2;top:0;left:0;width:3.5rem;height:100%;border-radius:6px 0 0 6px;border-right:1px solid rgba(0,0,0,.66);background-color:#282c34}div[class~=language-js]:before{content:"js"}div[class~=language-ts]:before{content:"ts"}div[class~=language-html]:before{content:"html"}div[class~=language-md]:before{content:"md"}div[class~=language-vue]:before{content:"vue"}div[class~=language-css]:before{content:"css"}div[class~=language-sass]:before{content:"sass"}div[class~=language-scss]:before{content:"scss"}div[class~=language-less]:before{content:"less"}div[class~=language-stylus]:before{content:"stylus"}div[class~=language-go]:before{content:"go"}div[class~=language-java]:before{content:"java"}div[class~=language-c]:before{content:"c"}div[class~=language-sh]:before{content:"sh"}div[class~=language-yaml]:before{content:"yaml"}div[class~=language-py]:before{content:"py"}div[class~=language-docker]:before{content:"docker"}div[class~=language-dockerfile]:before{content:"dockerfile"}div[class~=language-makefile]:before{content:"makefile"}div[class~=language-javascript]:before{content:"js"}div[class~=language-typescript]:before{content:"ts"}div[class~=language-markup]:before{content:"html"}div[class~=language-markdown]:before{content:"md"}div[class~=language-json]:before{content:"json"}div[class~=language-ruby]:before{content:"rb"}div[class~=language-python]:before{content:"py"}div[class~=language-bash]:before{content:"sh"}div[class~=language-php]:before{content:"php"}.custom-block .custom-block-title{font-weight:600;margin-bottom:-.4rem}.custom-block.danger,.custom-block.tip,.custom-block.warning{padding:.1rem 1.5rem;border-left-width:.5rem;border-left-style:solid;margin:1rem 0}.custom-block.tip{background-color:#f3f5f7;border-color:#42b983}.custom-block.warning{background-color:rgba(255,229,100,.3);border-color:#e7c000;color:#6b5900}.custom-block.warning .custom-block-title{color:#b29400}.custom-block.warning a{color:#2c3e50}.custom-block.danger{background-color:#ffe6e6;border-color:#c00;color:#4d0000}.custom-block.danger .custom-block-title{color:#900}.custom-block.danger a{color:#2c3e50}.custom-block.details{display:block;position:relative;border-radius:2px;margin:1.6em 0;padding:1.6em;background-color:#eee}.custom-block.details h4{margin-top:0}.custom-block.details figure:last-child,.custom-block.details p:last-child{margin-bottom:0;padding-bottom:0}.custom-block.details summary{outline:none;cursor:pointer}.arrow{display:inline-block;width:0;height:0}.arrow.up{border-bottom:6px solid #ccc}.arrow.down,.arrow.up{border-left:4px solid transparent;border-right:4px solid transparent}.arrow.down{border-top:6px solid #ccc}.arrow.right{border-left:6px solid #ccc}.arrow.left,.arrow.right{border-top:4px solid transparent;border-bottom:4px solid transparent}.arrow.left{border-right:6px solid #ccc}.theme-default-content:not(.custom){max-width:740px;margin:0 auto;padding:2rem 2.5rem}@media (max-width:959px){.theme-default-content:not(.custom){padding:2rem}}@media (max-width:419px){.theme-default-content:not(.custom){padding:1.5rem}}.table-of-contents .badge{vertical-align:middle}body,html{padding:0;margin:0;background-color:#fff}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:16px;color:#2c3e50}.page{padding-left:25rem}.navbar{z-index:20;right:0;height:3.6rem;background-color:#fff;box-sizing:border-box;border-bottom:1px solid #eaecef}.navbar,.sidebar-mask{position:fixed;top:0;left:0}.sidebar-mask{z-index:9;width:100vw;height:100vh;display:none}.sidebar{font-size:16px;background-color:#fff;width:25rem;position:fixed;z-index:10;margin:0;top:3.6rem;left:0;bottom:0;box-sizing:border-box;border-right:1px solid #eaecef;overflow-y:auto}.theme-default-content:not(.custom)>:first-child{margin-top:3.6rem}.theme-default-content:not(.custom) a:hover{text-decoration:underline}.theme-default-content:not(.custom) p.demo{padding:1rem 1.5rem;border:1px solid #ddd;border-radius:4px}.theme-default-content:not(.custom) img{max-width:100%}.theme-default-content.custom{padding:0;margin:0}.theme-default-content.custom img{max-width:100%}a{font-weight:500;text-decoration:none}a,p a code{color:#3eaf7c}p a code{font-weight:400}kbd{background:#eee;border:.15rem solid #ddd;border-bottom:.25rem solid #ddd;border-radius:.15rem;padding:0 .15em}blockquote{font-size:1rem;color:#999;border-left:.2rem solid #dfe2e5;margin:1rem 0;padding:.25rem 0 .25rem 1rem}blockquote>p{margin:0}ol,ul{padding-left:1.2em}strong{font-weight:600}h1,h2,h3,h4,h5,h6{font-weight:600;line-height:1.25}.theme-default-content:not(.custom)>h1,.theme-default-content:not(.custom)>h2,.theme-default-content:not(.custom)>h3,.theme-default-content:not(.custom)>h4,.theme-default-content:not(.custom)>h5,.theme-default-content:not(.custom)>h6{margin-top:-3.1rem;padding-top:4.6rem;margin-bottom:0}.theme-default-content:not(.custom)>h1:first-child,.theme-default-content:not(.custom)>h2:first-child,.theme-default-content:not(.custom)>h3:first-child,.theme-default-content:not(.custom)>h4:first-child,.theme-default-content:not(.custom)>h5:first-child,.theme-default-content:not(.custom)>h6:first-child{margin-top:-1.5rem;margin-bottom:1rem}.theme-default-content:not(.custom)>h1:first-child+.custom-block,.theme-default-content:not(.custom)>h1:first-child+p,.theme-default-content:not(.custom)>h1:first-child+pre,.theme-default-content:not(.custom)>h2:first-child+.custom-block,.theme-default-content:not(.custom)>h2:first-child+p,.theme-default-content:not(.custom)>h2:first-child+pre,.theme-default-content:not(.custom)>h3:first-child+.custom-block,.theme-default-content:not(.custom)>h3:first-child+p,.theme-default-content:not(.custom)>h3:first-child+pre,.theme-default-content:not(.custom)>h4:first-child+.custom-block,.theme-default-content:not(.custom)>h4:first-child+p,.theme-default-content:not(.custom)>h4:first-child+pre,.theme-default-content:not(.custom)>h5:first-child+.custom-block,.theme-default-content:not(.custom)>h5:first-child+p,.theme-default-content:not(.custom)>h5:first-child+pre,.theme-default-content:not(.custom)>h6:first-child+.custom-block,.theme-default-content:not(.custom)>h6:first-child+p,.theme-default-content:not(.custom)>h6:first-child+pre{margin-top:2rem}h1:focus .header-anchor,h1:hover .header-anchor,h2:focus .header-anchor,h2:hover .header-anchor,h3:focus .header-anchor,h3:hover .header-anchor,h4:focus .header-anchor,h4:hover .header-anchor,h5:focus .header-anchor,h5:hover .header-anchor,h6:focus .header-anchor,h6:hover .header-anchor{opacity:1}h1{font-size:2.2rem}h2{font-size:1.65rem;padding-bottom:.3rem;border-bottom:1px solid #eaecef}h3{font-size:1.35rem}a.header-anchor{font-size:.85em;float:left;margin-left:-.87em;padding-right:.23em;margin-top:.125em;opacity:0}a.header-anchor:focus,a.header-anchor:hover{text-decoration:none}.line-number,code,kbd{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}ol,p,ul{line-height:1.7}hr{border:0;border-top:1px solid #eaecef}table{border-collapse:collapse;margin:1rem 0;display:block;overflow-x:auto}tr{border-top:1px solid #dfe2e5}tr:nth-child(2n){background-color:#f6f8fa}td,th{border:1px solid #dfe2e5;padding:.6em 1em}.theme-container.sidebar-open .sidebar-mask{display:block}.theme-container.no-navbar .theme-default-content:not(.custom)>h1,.theme-container.no-navbar h2,.theme-container.no-navbar h3,.theme-container.no-navbar h4,.theme-container.no-navbar h5,.theme-container.no-navbar h6{margin-top:1.5rem;padding-top:0}.theme-container.no-navbar .sidebar{top:0}@media (min-width:720px){.theme-container.no-sidebar .sidebar{display:none}.theme-container.no-sidebar .page{padding-left:0}}@media (max-width:959px){.sidebar{font-size:15px;width:20.5rem}.page{padding-left:20.5rem}}@media (max-width:719px){.sidebar{top:0;padding-top:3.6rem;transform:translateX(-100%);transition:transform .2s ease}.page{padding-left:0}.theme-container.sidebar-open .sidebar{transform:translateX(0)}.theme-container.no-navbar .sidebar{padding-top:0}}@media (max-width:419px){h1{font-size:1.9rem}.theme-default-content div[class*=language-]{margin:.85rem -1.5rem;border-radius:0}}.home .hero img{max-width:450px!important}#nprogress{pointer-events:none}#nprogress .bar{background:#3eaf7c;position:fixed;z-index:1031;top:0;left:0;width:100%;height:2px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;box-shadow:0 0 10px #3eaf7c,0 0 5px #3eaf7c;opacity:1;transform:rotate(3deg) translateY(-4px)}#nprogress .spinner{display:block;position:fixed;z-index:1031;top:15px;right:15px}#nprogress .spinner-icon{width:18px;height:18px;box-sizing:border-box;border-color:#3eaf7c transparent transparent #3eaf7c;border-style:solid;border-width:2px;border-radius:50%;-webkit-animation:nprogress-spinner .4s linear infinite;animation:nprogress-spinner .4s linear infinite}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .bar,.nprogress-custom-parent #nprogress .spinner{position:absolute}@-webkit-keyframes nprogress-spinner{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes nprogress-spinner{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.icon.outbound{color:#aaa;display:inline-block;vertical-align:middle;position:relative;top:-1px}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.home{padding:3.6rem 2rem 0;max-width:960px;margin:0 auto;display:block}.home .hero{text-align:center}.home .hero img{max-width:100%;max-height:280px;display:block;margin:3rem auto 1.5rem}.home .hero h1{font-size:3rem}.home .hero .action,.home .hero .description,.home .hero h1{margin:1.8rem auto}.home .hero .description{max-width:35rem;font-size:1.6rem;line-height:1.3;color:#6a8bad}.home .hero .action-button{display:inline-block;font-size:1.2rem;color:#fff;background-color:#3eaf7c;padding:.8rem 1.6rem;border-radius:4px;transition:background-color .1s ease;box-sizing:border-box;border-bottom:1px solid #389d70}.home .hero .action-button:hover{background-color:#4abf8a}.home .features{border-top:1px solid #eaecef;padding:1.2rem 0;margin-top:2.5rem;display:flex;flex-wrap:wrap;align-items:flex-start;align-content:stretch;justify-content:space-between}.home .feature{flex-grow:1;flex-basis:30%;max-width:30%}.home .feature h2{font-size:1.4rem;font-weight:500;border-bottom:none;padding-bottom:0;color:#3a5169}.home .feature p{color:#4e6e8e}.home .footer{padding:2.5rem;border-top:1px solid #eaecef;text-align:center;color:#4e6e8e}@media (max-width:719px){.home .features{flex-direction:column}.home .feature{max-width:100%;padding:0 2.5rem}}@media (max-width:419px){.home{padding-left:1.5rem;padding-right:1.5rem}.home .hero img{max-height:210px;margin:2rem auto 1.2rem}.home .hero h1{font-size:2rem}.home .hero .action,.home .hero .description,.home .hero h1{margin:1.2rem auto}.home .hero .description{font-size:1.2rem}.home .hero .action-button{font-size:1rem;padding:.6rem 1.2rem}.home .feature h2{font-size:1.25rem}}.search-box{display:inline-block;position:relative;margin-right:1rem}.search-box input{cursor:text;width:10rem;height:2rem;color:#4e6e8e;display:inline-block;border:1px solid #cfd4db;border-radius:2rem;font-size:.9rem;line-height:2rem;padding:0 .5rem 0 2rem;outline:none;transition:all .2s ease;background:#fff url(/aws-lambda-java-runtime/assets/img/search.83621669.svg) .6rem .5rem no-repeat;background-size:1rem}.search-box input:focus{cursor:auto;border-color:#3eaf7c}.search-box .suggestions{background:#fff;width:20rem;position:absolute;top:2rem;border:1px solid #cfd4db;border-radius:6px;padding:.4rem;list-style-type:none}.search-box .suggestions.align-right{right:0}.search-box .suggestion{line-height:1.4;padding:.4rem .6rem;border-radius:4px;cursor:pointer}.search-box .suggestion a{white-space:normal;color:#5d82a6}.search-box .suggestion a .page-title{font-weight:600}.search-box .suggestion a .header{font-size:.9em;margin-left:.25em}.search-box .suggestion.focused{background-color:#f3f4f5}.search-box .suggestion.focused a{color:#3eaf7c}@media (max-width:959px){.search-box input{cursor:pointer;width:0;border-color:transparent;position:relative}.search-box input:focus{cursor:text;left:0;width:10rem}}@media (-ms-high-contrast:none){.search-box input{height:2rem}}@media (max-width:959px) and (min-width:719px){.search-box .suggestions{left:0}}@media (max-width:719px){.search-box{margin-right:0}.search-box input{left:1rem}.search-box .suggestions{right:0}}@media (max-width:419px){.search-box .suggestions{width:calc(100vw - 4rem)}.search-box input:focus{width:8rem}}.sidebar-button{cursor:pointer;display:none;width:1.25rem;height:1.25rem;position:absolute;padding:.6rem;top:.6rem;left:1rem}.sidebar-button .icon{display:block;width:1.25rem;height:1.25rem}@media (max-width:719px){.sidebar-button{display:block}}.dropdown-enter,.dropdown-leave-to{height:0!important}.dropdown-wrapper{cursor:pointer}.dropdown-wrapper .dropdown-title,.dropdown-wrapper .mobile-dropdown-title{display:block;font-size:.9rem;font-family:inherit;cursor:inherit;padding:inherit;line-height:1.4rem;background:transparent;border:none;font-weight:500;color:#2c3e50}.dropdown-wrapper .dropdown-title:hover,.dropdown-wrapper .mobile-dropdown-title:hover{border-color:transparent}.dropdown-wrapper .dropdown-title .arrow,.dropdown-wrapper .mobile-dropdown-title .arrow{vertical-align:middle;margin-top:-1px;margin-left:.4rem}.dropdown-wrapper .mobile-dropdown-title{display:none;font-weight:600}.dropdown-wrapper .mobile-dropdown-title font-size inherit:hover{color:#3eaf7c}.dropdown-wrapper .nav-dropdown .dropdown-item{color:inherit;line-height:1.7rem}.dropdown-wrapper .nav-dropdown .dropdown-item h4{margin:.45rem 0 0;border-top:1px solid #eee;padding:1rem 1.5rem .45rem 1.25rem}.dropdown-wrapper .nav-dropdown .dropdown-item .dropdown-subitem-wrapper{padding:0;list-style:none}.dropdown-wrapper .nav-dropdown .dropdown-item .dropdown-subitem-wrapper .dropdown-subitem{font-size:.9em}.dropdown-wrapper .nav-dropdown .dropdown-item a{display:block;line-height:1.7rem;position:relative;border-bottom:none;font-weight:400;margin-bottom:0;padding:0 1.5rem 0 1.25rem}.dropdown-wrapper .nav-dropdown .dropdown-item a.router-link-active,.dropdown-wrapper .nav-dropdown .dropdown-item a:hover{color:#3eaf7c}.dropdown-wrapper .nav-dropdown .dropdown-item a.router-link-active:after{content:"";width:0;height:0;border-left:5px solid #3eaf7c;border-top:3px solid transparent;border-bottom:3px solid transparent;position:absolute;top:calc(50% - 2px);left:9px}.dropdown-wrapper .nav-dropdown .dropdown-item:first-child h4{margin-top:0;padding-top:0;border-top:0}@media (max-width:719px){.dropdown-wrapper.open .dropdown-title{margin-bottom:.5rem}.dropdown-wrapper .dropdown-title{display:none}.dropdown-wrapper .mobile-dropdown-title{display:block}.dropdown-wrapper .nav-dropdown{transition:height .1s ease-out;overflow:hidden}.dropdown-wrapper .nav-dropdown .dropdown-item h4{border-top:0;margin-top:0;padding-top:0}.dropdown-wrapper .nav-dropdown .dropdown-item>a,.dropdown-wrapper .nav-dropdown .dropdown-item h4{font-size:15px;line-height:2rem}.dropdown-wrapper .nav-dropdown .dropdown-item .dropdown-subitem{font-size:14px;padding-left:1rem}}@media (min-width:719px){.dropdown-wrapper{height:1.8rem}.dropdown-wrapper.open .nav-dropdown,.dropdown-wrapper:hover .nav-dropdown{display:block!important}.dropdown-wrapper.open:blur{display:none}.dropdown-wrapper .nav-dropdown{display:none;height:auto!important;box-sizing:border-box;max-height:calc(100vh - 2.7rem);overflow-y:auto;position:absolute;top:100%;right:0;background-color:#fff;padding:.6rem 0;border:1px solid;border-color:#ddd #ddd #ccc;text-align:left;border-radius:.25rem;white-space:nowrap;margin:0}}.nav-links{display:inline-block}.nav-links a{line-height:1.4rem;color:inherit}.nav-links a.router-link-active,.nav-links a:hover{color:#3eaf7c}.nav-links .nav-item{position:relative;display:inline-block;margin-left:1.5rem;line-height:2rem}.nav-links .nav-item:first-child{margin-left:0}.nav-links .repo-link{margin-left:1.5rem}@media (max-width:719px){.nav-links .nav-item,.nav-links .repo-link{margin-left:0}}@media (min-width:719px){.nav-links a.router-link-active,.nav-links a:hover{color:#2c3e50}.nav-item>a:not(.external).router-link-active,.nav-item>a:not(.external):hover{margin-bottom:-2px;border-bottom:2px solid #46bd87}}.navbar{padding:.7rem 1.5rem;line-height:2.2rem}.navbar a,.navbar img,.navbar span{display:inline-block}.navbar .logo{height:2.2rem;min-width:2.2rem;margin-right:.8rem;vertical-align:top}.navbar .site-name{font-size:1.3rem;font-weight:600;color:#2c3e50;position:relative}.navbar .links{padding-left:1.5rem;box-sizing:border-box;background-color:#fff;white-space:nowrap;font-size:.9rem;position:absolute;right:1.5rem;top:.7rem;display:flex}.navbar .links .search-box{flex:0 0 auto;vertical-align:top}@media (max-width:719px){.navbar{padding-left:4rem}.navbar .can-hide{display:none}.navbar .links{padding-left:1.5rem}.navbar .site-name{width:calc(100vw - 9.4rem);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}}.page-edit{max-width:740px;margin:0 auto;padding:2rem 2.5rem}@media (max-width:959px){.page-edit{padding:2rem}}@media (max-width:419px){.page-edit{padding:1.5rem}}.page-edit{padding-top:1rem;padding-bottom:1rem;overflow:auto}.page-edit .edit-link{display:inline-block}.page-edit .edit-link a{color:#4e6e8e;margin-right:.25rem}.page-edit .last-updated{float:right;font-size:.9em}.page-edit .last-updated .prefix{font-weight:500;color:#4e6e8e}.page-edit .last-updated .time{font-weight:400;color:#767676}@media (max-width:719px){.page-edit .edit-link{margin-bottom:.5rem}.page-edit .last-updated{font-size:.8em;float:none;text-align:left}}.page-nav{max-width:740px;margin:0 auto;padding:2rem 2.5rem}@media (max-width:959px){.page-nav{padding:2rem}}@media (max-width:419px){.page-nav{padding:1.5rem}}.page-nav{padding-top:1rem;padding-bottom:0}.page-nav .inner{min-height:2rem;margin-top:0;border-top:1px solid #eaecef;padding-top:1rem;overflow:auto}.page-nav .next{float:right}.page{padding-bottom:2rem;display:block}.sidebar-group .sidebar-group{padding-left:.5em}.sidebar-group:not(.collapsable) .sidebar-heading:not(.clickable){cursor:auto;color:inherit}.sidebar-group.is-sub-group{padding-left:0}.sidebar-group.is-sub-group>.sidebar-heading{font-size:.95em;line-height:1.4;font-weight:400;padding-left:2rem}.sidebar-group.is-sub-group>.sidebar-heading:not(.clickable){opacity:.5}.sidebar-group.is-sub-group>.sidebar-group-items{padding-left:1rem}.sidebar-group.is-sub-group>.sidebar-group-items>li>.sidebar-link{font-size:.95em;border-left:none}.sidebar-group.depth-2>.sidebar-heading{border-left:none}.sidebar-heading{color:#2c3e50;transition:color .15s ease;cursor:pointer;font-size:1.1em;font-weight:700;padding:.35rem 1.5rem .35rem 1.25rem;width:100%;box-sizing:border-box;margin:0;border-left:.25rem solid transparent}.sidebar-heading.open,.sidebar-heading:hover{color:inherit}.sidebar-heading .arrow{position:relative;top:-.12em;left:.5em}.sidebar-heading.clickable.active{font-weight:600;color:#3eaf7c;border-left-color:#3eaf7c}.sidebar-heading.clickable:hover{color:#3eaf7c}.sidebar-group-items{transition:height .1s ease-out;font-size:.95em;overflow:hidden}.sidebar .sidebar-sub-headers{padding-left:1rem;font-size:.95em}a.sidebar-link{font-size:1em;font-weight:400;display:inline-block;color:#2c3e50;border-left:.25rem solid transparent;padding:.35rem 1rem .35rem 1.25rem;line-height:1.4;width:100%;box-sizing:border-box}a.sidebar-link:hover{color:#3eaf7c}a.sidebar-link.active{font-weight:600;color:#3eaf7c;border-left-color:#3eaf7c}.sidebar-group a.sidebar-link{padding-left:2rem}.sidebar-sub-headers a.sidebar-link{padding-top:.25rem;padding-bottom:.25rem;border-left:none}.sidebar-sub-headers a.sidebar-link.active{font-weight:500}.sidebar ul{padding:0;margin:0;list-style-type:none}.sidebar a{display:inline-block}.sidebar .nav-links{display:none;border-bottom:1px solid #eaecef;padding:.5rem 0 .75rem}.sidebar .nav-links a{font-weight:600}.sidebar .nav-links .nav-item,.sidebar .nav-links .repo-link{display:block;line-height:1.25rem;font-size:1.1em;padding:.5rem 0 .5rem 1.5rem}.sidebar>.sidebar-links{padding:1.5rem 0}.sidebar>.sidebar-links>li>a.sidebar-link{font-size:1.1em;line-height:1.7;font-weight:700}.sidebar>.sidebar-links>li:not(:first-child){margin-top:.75rem}@media (max-width:719px){.sidebar .nav-links{display:block}.sidebar .nav-links .dropdown-wrapper .nav-dropdown .dropdown-item a.router-link-active:after{top:calc(1rem - 2px)}.sidebar>.sidebar-links{padding:1rem 0}}.badge[data-v-15b7b770]{display:inline-block;font-size:14px;height:18px;line-height:18px;border-radius:3px;padding:0 6px;color:#fff}.badge.green[data-v-15b7b770],.badge.tip[data-v-15b7b770],.badge[data-v-15b7b770]{background-color:#42b983}.badge.error[data-v-15b7b770]{background-color:#da5961}.badge.warn[data-v-15b7b770],.badge.warning[data-v-15b7b770],.badge.yellow[data-v-15b7b770]{background-color:#e7c000}.badge+.badge[data-v-15b7b770]{margin-left:5px}.theme-code-block[data-v-759a7d02]{display:none}.theme-code-block__active[data-v-759a7d02]{display:block}.theme-code-block>pre[data-v-759a7d02]{background-color:orange}.theme-code-group__nav[data-v-deefee04]{margin-bottom:-35px;background-color:#282c34;padding-bottom:22px;border-top-left-radius:6px;border-top-right-radius:6px;padding-left:10px;padding-top:10px}.theme-code-group__ul[data-v-deefee04]{margin:auto 0;padding-left:0;display:inline-flex;list-style:none}.theme-code-group__nav-tab[data-v-deefee04]{border:0;padding:5px;cursor:pointer;background-color:transparent;font-size:.85em;line-height:1.4;color:hsla(0,0%,100%,.9);font-weight:600}.theme-code-group__nav-tab-active[data-v-deefee04]{border-bottom:1px solid #42b983}.pre-blank[data-v-deefee04]{color:#42b983} -------------------------------------------------------------------------------- /docs/assets/img/search.83621669.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/assets/js/3.597e5726.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[3],{328:function(t,e,n){},356:function(t,e,n){"use strict";n(328)},366:function(t,e,n){"use strict";n.r(e);var i={functional:!0,props:{type:{type:String,default:"tip"},text:String,vertical:{type:String,default:"top"}},render:function(t,e){var n=e.props,i=e.slots;return t("span",{class:["badge",n.type],style:{verticalAlign:n.vertical}},n.text||i().default)}},r=(n(356),n(45)),p=Object(r.a)(i,void 0,void 0,!1,null,"15b7b770",null);e.default=p.exports}}]); -------------------------------------------------------------------------------- /docs/assets/js/4.09ee8a39.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[4],{329:function(t,e,a){},357:function(t,e,a){"use strict";a(329)},361:function(t,e,a){"use strict";a.r(e);var n={name:"CodeBlock",props:{title:{type:String,required:!0},active:{type:Boolean,default:!1}},mounted:function(){this.$parent&&this.$parent.loadTabs&&this.$parent.loadTabs()}},i=(a(357),a(45)),s=Object(i.a)(n,(function(){var t=this.$createElement;return(this._self._c||t)("div",{staticClass:"theme-code-block",class:{"theme-code-block__active":this.active}},[this._t("default")],2)}),[],!1,null,"759a7d02",null);e.default=s.exports}}]); -------------------------------------------------------------------------------- /docs/assets/js/5.c661e667.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[5],{330:function(e,t,a){},358:function(e,t,a){"use strict";a(330)},362:function(e,t,a){"use strict";a.r(t);a(66),a(27),a(94),a(95);var o={name:"CodeGroup",data:function(){return{codeTabs:[],activeCodeTabIndex:-1}},watch:{activeCodeTabIndex:function(e){this.activateCodeTab(e)}},mounted:function(){this.loadTabs()},methods:{changeCodeTab:function(e){this.activeCodeTabIndex=e},loadTabs:function(){var e=this;this.codeTabs=(this.$slots.default||[]).filter((function(e){return Boolean(e.componentOptions)})).map((function(t,a){return""===t.componentOptions.propsData.active&&(e.activeCodeTabIndex=a),{title:t.componentOptions.propsData.title,elm:t.elm}})),-1===this.activeCodeTabIndex&&this.codeTabs.length>0&&(this.activeCodeTabIndex=0),this.activateCodeTab(0)},activateCodeTab:function(e){this.codeTabs.forEach((function(e){e.elm&&e.elm.classList.remove("theme-code-block__active")})),this.codeTabs[e].elm&&this.codeTabs[e].elm.classList.add("theme-code-block__active")}}},n=(a(358),a(45)),c=Object(n.a)(o,(function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("ClientOnly",[a("div",{staticClass:"theme-code-group"},[a("div",{staticClass:"theme-code-group__nav"},[a("ul",{staticClass:"theme-code-group__ul"},e._l(e.codeTabs,(function(t,o){return a("li",{key:t.title,staticClass:"theme-code-group__li"},[a("button",{staticClass:"theme-code-group__nav-tab",class:{"theme-code-group__nav-tab-active":o===e.activeCodeTabIndex},on:{click:function(t){return e.changeCodeTab(o)}}},[e._v("\n "+e._s(t.title)+"\n ")])])})),0)]),e._v(" "),e._t("default"),e._v(" "),e.codeTabs.length<1?a("pre",{staticClass:"pre-blank"},[e._v("// Make sure to add code blocks to your code group")]):e._e()],2)])}),[],!1,null,"deefee04",null);t.default=c.exports}}]); -------------------------------------------------------------------------------- /docs/assets/js/6.aa86b854.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[6],{360:function(t,e,s){"use strict";s.r(e);var n=["There's nothing here.","How did we get here?","That's a Four-Oh-Four.","Looks like we've got some broken links."],o={methods:{getMsg:function(){return n[Math.floor(Math.random()*n.length)]}}},i=s(45),h=Object(i.a)(o,(function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"theme-container"},[e("div",{staticClass:"theme-default-content"},[e("h1",[this._v("404")]),this._v(" "),e("blockquote",[this._v(this._s(this.getMsg()))]),this._v(" "),e("RouterLink",{attrs:{to:"/"}},[this._v("\n Take me home.\n ")])],1)])}),[],!1,null,null,null);e.default=h.exports}}]); -------------------------------------------------------------------------------- /docs/assets/js/7.9d661306.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[7],{363:function(t,a,e){"use strict";e.r(a);var s=e(45),r=Object(s.a)({},(function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[e("h1",{attrs:{id:"changelog"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#changelog"}},[t._v("#")]),t._v(" Changelog")]),t._v(" "),e("h2",{attrs:{id:"_0-0-2-snapshot"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#_0-0-2-snapshot"}},[t._v("#")]),t._v(" 0.0.2-SNAPSHOT")]),t._v(" "),e("p",[t._v("TBD")]),t._v(" "),e("h2",{attrs:{id:"_0-0-1"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#_0-0-1"}},[t._v("#")]),t._v(" 0.0.1")]),t._v(" "),e("ul",[e("li",[t._v("Initial release")])]),t._v(" "),e("p",[t._v("Released at 2021-04-05")])])}),[],!1,null,null,null);a.default=r.exports}}]); -------------------------------------------------------------------------------- /docs/assets/js/8.3277f56e.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[8],{364:function(t,a,e){"use strict";e.r(a);var n=e(45),o=Object(n.a)({},(function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[e("h1",{attrs:{id:"introduction"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#introduction"}},[t._v("#")]),t._v(" Introduction")]),t._v(" "),e("p",[t._v("Serverless computing is getting more and more popular. One of the cloud providers supporting\na service like this is AWS, and the corresponding AWS Lambda service.")]),t._v(" "),e("p",[t._v("Java is a great language to write scalable and maintainable applications. However, for\nserverless computing it was not the best choice because of slow cold-starts. Until now.")]),t._v(" "),e("p",[t._v("With this customized runtime, you can speed up your Java Lambda functions. Instead of\nspinning up a full JVM in AWS Lambda, it's possible to use GraalVM and compile a standalone\nnative executable and run it without any additional overhead.")]),t._v(" "),e("h2",{attrs:{id:"quickstart"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#quickstart"}},[t._v("#")]),t._v(" Quickstart")]),t._v(" "),e("p",[t._v("For now, the quickstart can be found on my blog: "),e("a",{attrs:{href:"https://arnoldgalovics.com/tackling-java-cold-startup-times-on-aws-lambda-with-graalvm/",target:"_blank",rel:"noopener noreferrer"}},[t._v("Tackling Java cold startup times on AWS Lambda with GraalVM"),e("OutboundLink")],1),t._v(".")])])}),[],!1,null,null,null);a.default=o.exports}}]); -------------------------------------------------------------------------------- /docs/assets/js/9.a78832c6.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[9],{365:function(t,a,e){"use strict";e.r(a);var n=e(45),o=Object(n.a)({},(function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[e("h1",{attrs:{id:"troubleshooting"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#troubleshooting"}},[t._v("#")]),t._v(" Troubleshooting")]),t._v(" "),e("h2",{attrs:{id:"the-lambda-function-is-reporting-runtime-invalidentrypoint"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#the-lambda-function-is-reporting-runtime-invalidentrypoint"}},[t._v("#")]),t._v(" The Lambda function is reporting Runtime.InvalidEntrypoint")]),t._v(" "),e("h3",{attrs:{id:"symptom"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#symptom"}},[t._v("#")]),t._v(" Symptom")]),t._v(" "),e("div",{staticClass:"language-text extra-class"},[e("pre",{pre:!0,attrs:{class:"language-text"}},[e("code",[t._v('{\n "errorMessage": "RequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f Error: fork/exec /var/task/bootstrap: no such file or directory",\n "errorType": "Runtime.InvalidEntrypoint"\n}\n\nSTART RequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f Version: $LATEST\nEND RequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f\nREPORT RequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f\tDuration: 0.69 ms\tBilled Duration: 1 ms\tMemory Size: 128 MB\tMax Memory Used: 5 MB\t\nRequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f Error: fork/exec /var/task/bootstrap: no such file or directory\nRuntime.InvalidEntrypoint\n')])])]),e("h3",{attrs:{id:"solution"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#solution"}},[t._v("#")]),t._v(" Solution")]),t._v(" "),e("p",[t._v("The "),e("code",[t._v("boostrap")]),t._v(" file has CRLF instead of LF. Convert the line endings, and re-upload the package.")]),t._v(" "),e("h2",{attrs:{id:"unable-to-create-proxy-class"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#unable-to-create-proxy-class"}},[t._v("#")]),t._v(" Unable to create Proxy class")]),t._v(" "),e("h3",{attrs:{id:"symptom-2"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#symptom-2"}},[t._v("#")]),t._v(" Symptom")]),t._v(" "),e("div",{staticClass:"language-text extra-class"},[e("pre",{pre:!0,attrs:{class:"language-text"}},[e("code",[t._v('This indicates you are using an old version (< 4.5.8) of Apache http client. It is recommended to use http client version >= 4.5.9 to avoid the breaking change introduced in apache client 4.5.7 and the latency in exception handling. See https://github.com/aws/aws-sdk-java/issues/1919 for more information \nException in thread "main" com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.apache.http.conn.ConnectionRequest, interface com.amazonaws.http.conn.Wrapped] not found. Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image build time by specifying the list of interfaces that they implement. To define proxy classes use -H:DynamicProxyConfigurationFiles= and -H:DynamicProxyConfigurationResources= options.\n\tat com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:87)\n\tat com.oracle.svm.reflect.proxy.DynamicProxySupport.getProxyClass(DynamicProxySupport.java:113)\n\tat java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:66)\n\tat java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1006)\n\tat com.amazonaws.http.conn.ClientConnectionRequestFactory.wrap(ClientConnectionRequestFactory.java:45)\n\tat com.amazonaws.http.conn.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:78)\n\tat com.amazonaws.http.conn.$Proxy148.requestConnection(Unknown Source)\n\tat org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:176)\n\tat org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)\n\tat org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)\n\tat org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)\n\tat org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)\n\tat com.amazonaws.http.apache.client.impl.SdkHttpClient.execute(SdkHttpClient.java:72)\n\tat com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1331)\n\tat com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1145)\n\tat com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:802)\n\tat com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:770)\n\tat com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:744)\n\tat com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:704)\n\tat com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:686)\n\tat com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:550)\n\tat com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:530)\n\tat com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.doInvoke(AmazonDynamoDBClient.java:6214)\n\tat com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:6181)\n\tat com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.executePutItem(AmazonDynamoDBClient.java:3793)\n\tat com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.putItem(AmazonDynamoDBClient.java:3757)\n\tat com.arnoldgalovics.blog.app.TestRequestHandler.handleRequest(TestRequestHandler.java:24)\n\tat com.arnoldgalovics.blog.app.TestRequestHandler.handleRequest(TestRequestHandler.java:14)\n\tat io.redskap.lambda.runtime.internal.RequestHandlerInvoker.internalInvokeHandler(RequestHandlerInvoker.java:20)\n\tat io.redskap.lambda.runtime.internal.RequestHandlerInvoker.invokeHandler(RequestHandlerInvoker.java:10)\n\tat io.redskap.lambda.runtime.LambdaRuntime.run(LambdaRuntime.java:37)\n\tat com.arnoldgalovics.blog.app.JavaApp.main(JavaApp.java:21)\nEND RequestId: 1fa87a52-03db-478f-9b7e-92ce62d445cd\nREPORT RequestId: 1fa87a52-03db-478f-9b7e-92ce62d445cd\tDuration: 169.66 ms\tBilled Duration: 181 ms\tMemory Size: 131 MB\tMax Memory Used: 32 MB\tInit Duration: 11.10 ms\t\nRequestId: 1fa87a52-03db-478f-9b7e-92ce62d445cd Error: Runtime exited with error: exit status 1\nRuntime.ExitError\n')])])]),e("h3",{attrs:{id:"solution-2"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#solution-2"}},[t._v("#")]),t._v(" Solution")]),t._v(" "),e("p",[t._v("When building with GraalVM, the classes are pre-compiled into the executable. In case of interface-based runtime proxies,\nGraalVM should know which interfaces will be implemented by the proxy class.")]),t._v(" "),e("p",[t._v("This can be configured via the "),e("code",[t._v("proxy-config.json")]),t._v(" file within "),e("code",[t._v("META-INF/native-image/...")]),t._v(" folder.")]),t._v(" "),e("p",[t._v("Example configuration for the AWS DynamoDB SDK:")]),t._v(" "),e("div",{staticClass:"language-json extra-class"},[e("pre",{pre:!0,attrs:{class:"language-json"}},[e("code",[e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"org.apache.http.conn.HttpClientConnectionManager"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"org.apache.http.pool.ConnPoolControl"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"com.amazonaws.http.conn.Wrapped"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"org.apache.http.conn.ConnectionRequest"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"com.amazonaws.http.conn.Wrapped"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n")])])]),e("h2",{attrs:{id:"classnotfoundexception-during-execution"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#classnotfoundexception-during-execution"}},[t._v("#")]),t._v(" ClassNotFoundException during execution")]),t._v(" "),e("h3",{attrs:{id:"symptom-3"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#symptom-3"}},[t._v("#")]),t._v(" Symptom")]),t._v(" "),e("div",{staticClass:"language-text extra-class"},[e("pre",{pre:!0,attrs:{class:"language-text"}},[e("code",[t._v("START RequestId: 9a97e354-1089-47cf-8d47-1c48edd1e7d1 Version: $LATEST\ncom.amazonaws.SdkClientException: Unable to calculate a request signature: Unable to calculate a request signature: No installed provider supports this key: javax.crypto.spec.SecretKeySpec\n\tat com.amazonaws.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:109)\n\tat com.amazonaws.auth.AWS4Signer.newSigningKey(AWS4Signer.java:639)\n\tat com.amazonaws.auth.AWS4Signer.deriveSigningKey(AWS4Signer.java:404)\n\tat com.amazonaws.auth.AWS4Signer.sign(AWS4Signer.java:253)\n\tat com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1305)\n\tat com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1145)\n\tat com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:802)\n\tat com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:770)\n\tat com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:744)\n\tat com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:704)\n\tat com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:686)\n\tat com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:550)\n\tat com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:530)\n\tat com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.doInvoke(AmazonDynamoDBClient.java:6214)\n\tat com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:6181)\n\tat com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.executePutItem(AmazonDynamoDBClient.java:3793)\n\tat com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.putItem(AmazonDynamoDBClient.java:3757)\n\tat com.arnoldgalovics.blog.app.TestRequestHandler.handleRequest(TestRequestHandler.java:24)\n\tat com.arnoldgalovics.blog.app.TestRequestHandler.handleRequest(TestRequestHandler.java:14)\n\tat io.redskap.lambda.runtime.internal.RequestHandlerInvoker.internalInvokeHandler(RequestHandlerInvoker.java:20)\n\tat io.redskap.lambda.runtime.internal.RequestHandlerInvoker.invokeHandler(RequestHandlerInvoker.java:10)\n\tat io.redskap.lambda.runtime.LambdaRuntime.run(LambdaRuntime.java:37)\n\tat com.arnoldgalovics.blog.app.JavaApp.main(JavaApp.java:21)\nCaused by: com.amazonaws.SdkClientException: Unable to calculate a request signature: No installed provider supports this key: javax.crypto.spec.SecretKeySpec\n\tat com.amazonaws.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:132)\n\tat com.amazonaws.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:105)\n\t... 22 more\nCaused by: java.security.InvalidKeyException: No installed provider supports this key: javax.crypto.spec.SecretKeySpec\n\tat javax.crypto.Mac.chooseProvider(Mac.java:392)\n\tat javax.crypto.Mac.init(Mac.java:435)\n\tat com.amazonaws.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:127)\n\t... 23 more\nCaused by: java.security.NoSuchAlgorithmException: class configured for Mac (provider: SunJCE) cannot be found.\n\tat java.security.Provider$Service.getImplClass(Provider.java:1933)\n\tat java.security.Provider$Service.newInstance(Provider.java:1894)\n\tat javax.crypto.Mac.chooseProvider(Mac.java:365)\n\t... 25 more\nCaused by: java.lang.ClassNotFoundException: com.sun.crypto.provider.HmacCore$HmacSHA256\n\tat com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:60)\n\tat java.lang.Class.forName(DynamicHub.java:1247)\n\tat java.security.Provider$Service.getImplClass(Provider.java:1918)\n\t... 27 more\nEND RequestId: 9a97e354-1089-47cf-8d47-1c48edd1e7d1\nREPORT RequestId: 9a97e354-1089-47cf-8d47-1c48edd1e7d1\tDuration: 169.33 ms\tBilled Duration: 183 ms\tMemory Size: 131 MB\tMax Memory Used: 33 MB\tInit Duration: 13.63 ms\t\n")])])]),e("h3",{attrs:{id:"solution-3"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#solution-3"}},[t._v("#")]),t._v(" Solution")]),t._v(" "),e("p",[t._v("In case of the application using any type of reflection to access a class, GraalVM will not know about it\nduring AoT compilation. It needs to be told what these classes are in a file called "),e("code",[t._v("reflect-config.json")]),t._v(" within the\n"),e("code",[t._v("META-INF/native-image/...")]),t._v(" folder.")]),t._v(" "),e("p",[t._v("Example configuration:")]),t._v(" "),e("div",{staticClass:"language-json extra-class"},[e("pre",{pre:!0,attrs:{class:"language-json"}},[e("code",[e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),t._v("\n ...\n "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token property"}},[t._v('"name"')]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v('"com.sun.crypto.provider.HmacCore$HmacSHA256"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token property"}},[t._v('"allDeclaredFields"')]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token property"}},[t._v('"allDeclaredConstructors"')]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token property"}},[t._v('"allDeclaredMethods"')]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token property"}},[t._v('"allDeclaredClasses"')]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[t._v("true")]),t._v("\n "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n ...\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v("\n")])])])])}),[],!1,null,null,null);a.default=o.exports}}]); -------------------------------------------------------------------------------- /docs/changelog/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Changelog | AWS Lambda Java Runtime 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Introduction | AWS Lambda Java Runtime 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |

# Introduction

Serverless computing is getting more and more popular. One of the cloud providers supporting 31 | a service like this is AWS, and the corresponding AWS Lambda service.

Java is a great language to write scalable and maintainable applications. However, for 32 | serverless computing it was not the best choice because of slow cold-starts. Until now.

With this customized runtime, you can speed up your Java Lambda functions. Instead of 33 | spinning up a full JVM in AWS Lambda, it's possible to use GraalVM and compile a standalone 34 | native executable and run it without any additional overhead.

# Quickstart

For now, the quickstart can be found on my blog: Tackling Java cold startup times on AWS Lambda with GraalVM (opens new window).

39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /docs/troubleshooting/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Troubleshooting | AWS Lambda Java Runtime 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |

# Troubleshooting

# The Lambda function is reporting Runtime.InvalidEntrypoint

# Symptom

{
 31 |   "errorMessage": "RequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f Error: fork/exec /var/task/bootstrap: no such file or directory",
 32 |   "errorType": "Runtime.InvalidEntrypoint"
 33 | }
 34 | 
 35 | START RequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f Version: $LATEST
 36 | END RequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f
 37 | REPORT RequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f	Duration: 0.69 ms	Billed Duration: 1 ms	Memory Size: 128 MB	Max Memory Used: 5 MB	
 38 | RequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f Error: fork/exec /var/task/bootstrap: no such file or directory
 39 | Runtime.InvalidEntrypoint
 40 | 

# Solution

The boostrap file has CRLF instead of LF. Convert the line endings, and re-upload the package.

# Unable to create Proxy class

# Symptom

This indicates you are using an old version (< 4.5.8) of Apache http client. It is recommended to use http client version >= 4.5.9 to avoid the breaking change introduced in apache client 4.5.7 and the latency in exception handling. See https://github.com/aws/aws-sdk-java/issues/1919 for more information 
 41 | Exception in thread "main" com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.apache.http.conn.ConnectionRequest, interface com.amazonaws.http.conn.Wrapped] not found. Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image build time by specifying the list of interfaces that they implement. To define proxy classes use -H:DynamicProxyConfigurationFiles=<comma-separated-config-files> and -H:DynamicProxyConfigurationResources=<comma-separated-config-resources> options.
 42 | 	at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:87)
 43 | 	at com.oracle.svm.reflect.proxy.DynamicProxySupport.getProxyClass(DynamicProxySupport.java:113)
 44 | 	at java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:66)
 45 | 	at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1006)
 46 | 	at com.amazonaws.http.conn.ClientConnectionRequestFactory.wrap(ClientConnectionRequestFactory.java:45)
 47 | 	at com.amazonaws.http.conn.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:78)
 48 | 	at com.amazonaws.http.conn.$Proxy148.requestConnection(Unknown Source)
 49 | 	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:176)
 50 | 	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
 51 | 	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
 52 | 	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
 53 | 	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
 54 | 	at com.amazonaws.http.apache.client.impl.SdkHttpClient.execute(SdkHttpClient.java:72)
 55 | 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1331)
 56 | 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1145)
 57 | 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:802)
 58 | 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:770)
 59 | 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:744)
 60 | 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:704)
 61 | 	at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:686)
 62 | 	at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:550)
 63 | 	at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:530)
 64 | 	at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.doInvoke(AmazonDynamoDBClient.java:6214)
 65 | 	at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:6181)
 66 | 	at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.executePutItem(AmazonDynamoDBClient.java:3793)
 67 | 	at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.putItem(AmazonDynamoDBClient.java:3757)
 68 | 	at com.arnoldgalovics.blog.app.TestRequestHandler.handleRequest(TestRequestHandler.java:24)
 69 | 	at com.arnoldgalovics.blog.app.TestRequestHandler.handleRequest(TestRequestHandler.java:14)
 70 | 	at io.redskap.lambda.runtime.internal.RequestHandlerInvoker.internalInvokeHandler(RequestHandlerInvoker.java:20)
 71 | 	at io.redskap.lambda.runtime.internal.RequestHandlerInvoker.invokeHandler(RequestHandlerInvoker.java:10)
 72 | 	at io.redskap.lambda.runtime.LambdaRuntime.run(LambdaRuntime.java:37)
 73 | 	at com.arnoldgalovics.blog.app.JavaApp.main(JavaApp.java:21)
 74 | END RequestId: 1fa87a52-03db-478f-9b7e-92ce62d445cd
 75 | REPORT RequestId: 1fa87a52-03db-478f-9b7e-92ce62d445cd	Duration: 169.66 ms	Billed Duration: 181 ms	Memory Size: 131 MB	Max Memory Used: 32 MB	Init Duration: 11.10 ms	
 76 | RequestId: 1fa87a52-03db-478f-9b7e-92ce62d445cd Error: Runtime exited with error: exit status 1
 77 | Runtime.ExitError
 78 | 

# Solution

When building with GraalVM, the classes are pre-compiled into the executable. In case of interface-based runtime proxies, 79 | GraalVM should know which interfaces will be implemented by the proxy class.

This can be configured via the proxy-config.json file within META-INF/native-image/... folder.

Example configuration for the AWS DynamoDB SDK:

[
 80 |   ["org.apache.http.conn.HttpClientConnectionManager", "org.apache.http.pool.ConnPoolControl", "com.amazonaws.http.conn.Wrapped"],
 81 |   ["org.apache.http.conn.ConnectionRequest", "com.amazonaws.http.conn.Wrapped"]
 82 | ]
 83 | 

# ClassNotFoundException during execution

# Symptom

START RequestId: 9a97e354-1089-47cf-8d47-1c48edd1e7d1 Version: $LATEST
 84 | com.amazonaws.SdkClientException: Unable to calculate a request signature: Unable to calculate a request signature: No installed provider supports this key: javax.crypto.spec.SecretKeySpec
 85 | 	at com.amazonaws.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:109)
 86 | 	at com.amazonaws.auth.AWS4Signer.newSigningKey(AWS4Signer.java:639)
 87 | 	at com.amazonaws.auth.AWS4Signer.deriveSigningKey(AWS4Signer.java:404)
 88 | 	at com.amazonaws.auth.AWS4Signer.sign(AWS4Signer.java:253)
 89 | 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1305)
 90 | 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1145)
 91 | 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:802)
 92 | 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:770)
 93 | 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:744)
 94 | 	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:704)
 95 | 	at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:686)
 96 | 	at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:550)
 97 | 	at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:530)
 98 | 	at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.doInvoke(AmazonDynamoDBClient.java:6214)
 99 | 	at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:6181)
100 | 	at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.executePutItem(AmazonDynamoDBClient.java:3793)
101 | 	at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.putItem(AmazonDynamoDBClient.java:3757)
102 | 	at com.arnoldgalovics.blog.app.TestRequestHandler.handleRequest(TestRequestHandler.java:24)
103 | 	at com.arnoldgalovics.blog.app.TestRequestHandler.handleRequest(TestRequestHandler.java:14)
104 | 	at io.redskap.lambda.runtime.internal.RequestHandlerInvoker.internalInvokeHandler(RequestHandlerInvoker.java:20)
105 | 	at io.redskap.lambda.runtime.internal.RequestHandlerInvoker.invokeHandler(RequestHandlerInvoker.java:10)
106 | 	at io.redskap.lambda.runtime.LambdaRuntime.run(LambdaRuntime.java:37)
107 | 	at com.arnoldgalovics.blog.app.JavaApp.main(JavaApp.java:21)
108 | Caused by: com.amazonaws.SdkClientException: Unable to calculate a request signature: No installed provider supports this key: javax.crypto.spec.SecretKeySpec
109 | 	at com.amazonaws.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:132)
110 | 	at com.amazonaws.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:105)
111 | 	... 22 more
112 | Caused by: java.security.InvalidKeyException: No installed provider supports this key: javax.crypto.spec.SecretKeySpec
113 | 	at javax.crypto.Mac.chooseProvider(Mac.java:392)
114 | 	at javax.crypto.Mac.init(Mac.java:435)
115 | 	at com.amazonaws.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:127)
116 | 	... 23 more
117 | Caused by: java.security.NoSuchAlgorithmException: class configured for Mac (provider: SunJCE) cannot be found.
118 | 	at java.security.Provider$Service.getImplClass(Provider.java:1933)
119 | 	at java.security.Provider$Service.newInstance(Provider.java:1894)
120 | 	at javax.crypto.Mac.chooseProvider(Mac.java:365)
121 | 	... 25 more
122 | Caused by: java.lang.ClassNotFoundException: com.sun.crypto.provider.HmacCore$HmacSHA256
123 | 	at com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:60)
124 | 	at java.lang.Class.forName(DynamicHub.java:1247)
125 | 	at java.security.Provider$Service.getImplClass(Provider.java:1918)
126 | 	... 27 more
127 | END RequestId: 9a97e354-1089-47cf-8d47-1c48edd1e7d1
128 | REPORT RequestId: 9a97e354-1089-47cf-8d47-1c48edd1e7d1	Duration: 169.33 ms	Billed Duration: 183 ms	Memory Size: 131 MB	Max Memory Used: 33 MB	Init Duration: 13.63 ms	
129 | 

# Solution

In case of the application using any type of reflection to access a class, GraalVM will not know about it 130 | during AoT compilation. It needs to be told what these classes are in a file called reflect-config.json within the 131 | META-INF/native-image/... folder.

Example configuration:

[
132 |   ...
133 |   {
134 |     "name": "com.sun.crypto.provider.HmacCore$HmacSHA256",
135 |     "allDeclaredFields": true,
136 |     "allDeclaredConstructors": true,
137 |     "allDeclaredMethods": true,
138 |     "allDeclaredClasses": true
139 |   },
140 |   ...
141 | ]
142 | 
151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redskap/aws-lambda-java-runtime/27bc28a29d6384d1feb6f524697a25ac11a293b1/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .gradle -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | !**/src/main/**/build/ 5 | !**/src/test/**/build/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | bin/ 16 | !**/src/main/**/bin/ 17 | !**/src/test/**/bin/ 18 | 19 | ### IntelliJ IDEA ### 20 | .idea 21 | *.iws 22 | *.iml 23 | *.ipr 24 | out/ 25 | !**/src/main/**/out/ 26 | !**/src/test/**/out/ 27 | 28 | ### NetBeans ### 29 | /nbproject/private/ 30 | /nbbuild/ 31 | /dist/ 32 | /nbdist/ 33 | /.nb-gradle/ 34 | 35 | ### VS Code ### 36 | .vscode/ 37 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gradle:6.8.3-jdk11 as builder 2 | COPY --chown=gradle:gradle . /home/application 3 | WORKDIR /home/application 4 | RUN gradle clean shadowJar --no-daemon 5 | 6 | FROM amazon/aws-lambda-provided:al2.2021.03.22.18 as graalvm 7 | ENV LANG=en_US.UTF-8 8 | RUN yum install -y gcc gcc-c++ libc6-dev zlib1g-dev curl bash zlib zlib-devel zip tar gzip 9 | ENV GRAAL_VERSION 21.0.0.2 10 | ENV JDK_VERSION java11 11 | ENV GRAAL_FILENAME graalvm-ce-${JDK_VERSION}-linux-amd64-${GRAAL_VERSION}.tar.gz 12 | RUN curl -4 -L https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${GRAAL_VERSION}/${GRAAL_FILENAME} -o /tmp/${GRAAL_FILENAME} 13 | RUN tar -zxf /tmp/${GRAAL_FILENAME} -C /tmp \ 14 | && mv /tmp/graalvm-ce-${JDK_VERSION}-${GRAAL_VERSION} /usr/lib/graalvm 15 | RUN rm -rf /tmp/* 16 | CMD ["/usr/lib/graalvm/bin/native-image"] 17 | 18 | FROM graalvm 19 | COPY --from=builder /home/application/ /home/application/ 20 | WORKDIR /home/application 21 | ENV BUILT_JAR_NAME=aws-lambda-java-dynamodb-native-0.0.1-SNAPSHOT-all 22 | RUN /usr/lib/graalvm/bin/gu install native-image 23 | RUN /usr/lib/graalvm/bin/native-image --verbose -jar build/libs/${BUILT_JAR_NAME}.jar 24 | RUN mv ${BUILT_JAR_NAME} function 25 | RUN chmod 777 function 26 | RUN zip -j function.zip bootstrap function 27 | ENTRYPOINT ["bash"] -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -euo pipefail 3 | ./function -Xmx256m -Djava.library.path=$(pwd) -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.github.johnrengelman.shadow' version '6.1.0' 3 | id 'com.bmuschko.docker-remote-api' version '6.7.0' 4 | id 'java' 5 | } 6 | 7 | import com.bmuschko.gradle.docker.tasks.container.* 8 | import com.bmuschko.gradle.docker.tasks.image.* 9 | 10 | group = 'com.arnoldgalovics.blog' 11 | version = '0.0.1-SNAPSHOT' 12 | sourceCompatibility = '11' 13 | 14 | repositories { 15 | mavenCentral() 16 | } 17 | 18 | dependencies { 19 | implementation 'io.redskap:aws-lambda-java-runtime:0.0.1' 20 | implementation 'com.amazonaws:aws-java-sdk-dynamodb:1.11.991' 21 | implementation 'org.slf4j:jcl-over-slf4j:1.7.30' 22 | implementation 'io.symphonia:lambda-logging:1.0.3' 23 | 24 | testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1' 25 | testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1' 26 | } 27 | 28 | test { 29 | useJUnitPlatform() 30 | } 31 | 32 | shadowJar { 33 | manifest { 34 | attributes 'Main-Class': 'io.redskap.lambda.runtime.sample.NativeDynamoDBApp' 35 | } 36 | } 37 | 38 | task buildNativeImage(type: DockerBuildImage) { 39 | inputDir = project.rootDir 40 | images.add('aws-lambda-java-dynamodb-native') 41 | } 42 | 43 | task createContainer(type: DockerCreateContainer) { 44 | dependsOn buildNativeImage 45 | targetImageId buildNativeImage.getImageId() 46 | hostConfig.autoRemove = true 47 | tty = true 48 | } 49 | 50 | task startContainer(type: DockerStartContainer) { 51 | dependsOn createContainer 52 | targetContainerId createContainer.getContainerId() 53 | } 54 | 55 | task copyNativePackageFromContainer(type: DockerCopyFileFromContainer) { 56 | dependsOn startContainer 57 | targetContainerId createContainer.getContainerId() 58 | hostPath = "${project.buildDir}/function.zip" 59 | remotePath = '/home/application/function.zip' 60 | } 61 | 62 | task stopNativeContainer(type: DockerStopContainer) { 63 | dependsOn copyNativePackageFromContainer 64 | targetContainerId createContainer.getContainerId() 65 | } 66 | 67 | task buildNative() { 68 | dependsOn stopNativeContainer 69 | } -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redskap/aws-lambda-java-runtime/27bc28a29d6384d1feb6f524697a25ac11a293b1/samples/aws-lambda-java-dynamodb-native/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'aws-lambda-java-dynamodb-native' 2 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/src/main/java/io/redskap/lambda/runtime/sample/NativeDynamoDBApp.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.sample; 2 | 3 | import io.redskap.lambda.runtime.LambdaRuntime; 4 | import io.redskap.lambda.runtime.RequestHandlerRegistration; 5 | import io.redskap.lambda.runtime.validation.RequestHandlerRegistrationValidator; 6 | 7 | import static java.util.Collections.singleton; 8 | import static java.util.Collections.singletonList; 9 | 10 | public class NativeDynamoDBApp { 11 | public static void main(String[] args) { 12 | new LambdaRuntime(singletonList( 13 | new RequestHandlerRegistration<>(new TestRequestHandler(), TestRequest.class, String.class) 14 | ), new RequestHandlerRegistrationValidator(singleton(TestRequest.class))).run(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/src/main/java/io/redskap/lambda/runtime/sample/TestRequest.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.sample; 2 | 3 | public class TestRequest { 4 | private String name; 5 | 6 | public TestRequest() { 7 | } 8 | 9 | public String getName() { 10 | return name; 11 | } 12 | 13 | public void setName(String name) { 14 | this.name = name; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/src/main/java/io/redskap/lambda/runtime/sample/TestRequestHandler.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.sample; 2 | 3 | import com.amazonaws.regions.Regions; 4 | import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; 5 | import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder; 6 | import com.amazonaws.services.dynamodbv2.model.AttributeValue; 7 | import com.amazonaws.services.dynamodbv2.model.PutItemRequest; 8 | import com.amazonaws.services.lambda.runtime.Context; 9 | import com.amazonaws.services.lambda.runtime.RequestHandler; 10 | 11 | import java.util.HashMap; 12 | import java.util.UUID; 13 | 14 | public class TestRequestHandler implements RequestHandler { 15 | @Override 16 | public String handleRequest(TestRequest input, Context context) { 17 | AmazonDynamoDB dynamo = AmazonDynamoDBClientBuilder.standard().withRegion(Regions.EU_CENTRAL_1).build(); 18 | PutItemRequest putItemRequest = new PutItemRequest(); 19 | putItemRequest.setTableName("test-db"); 20 | HashMap items = new HashMap<>(); 21 | items.put("id", new AttributeValue(UUID.randomUUID().toString())); 22 | items.put("name", new AttributeValue(input.getName())); 23 | putItemRequest.setItem(items); 24 | dynamo.putItem(putItemRequest); 25 | return input.getName(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/src/main/resources/META-INF/native-image/io.redskap/aws-lambda-java-dynamodb-native/native-image.properties: -------------------------------------------------------------------------------- 1 | Args = --allow-incomplete-classpath --enable-url-protocols=https -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/src/main/resources/META-INF/native-image/io.redskap/aws-lambda-java-dynamodb-native/proxy-config.json: -------------------------------------------------------------------------------- 1 | [ 2 | ["org.apache.http.conn.HttpClientConnectionManager", "org.apache.http.pool.ConnPoolControl", "com.amazonaws.http.conn.Wrapped"], 3 | ["org.apache.http.conn.ConnectionRequest", "com.amazonaws.http.conn.Wrapped"] 4 | ] -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/src/main/resources/META-INF/native-image/io.redskap/aws-lambda-java-dynamodb-native/reflect-config.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "io.redskap.lambda.runtime.sample.TestRequest", 4 | "allDeclaredFields": true, 5 | "allDeclaredConstructors": true, 6 | "allDeclaredMethods": true, 7 | "allDeclaredClasses": true 8 | }, 9 | { 10 | "name": "org.apache.commons.logging.LogFactory", 11 | "allDeclaredFields": true, 12 | "allDeclaredConstructors": true, 13 | "allDeclaredMethods": true, 14 | "allDeclaredClasses": true 15 | }, 16 | { 17 | "name": "org.apache.commons.logging.impl.LogFactoryImpl", 18 | "allDeclaredFields": true, 19 | "allDeclaredConstructors": true, 20 | "allDeclaredMethods": true, 21 | "allDeclaredClasses": true 22 | }, 23 | { 24 | "name": "org.apache.commons.logging.impl.SLF4JLogFactory", 25 | "allDeclaredFields": true, 26 | "allDeclaredConstructors": true, 27 | "allDeclaredMethods": true, 28 | "allDeclaredClasses": true 29 | }, 30 | { 31 | "name": "io.symphonia.lambda.logging.DefaultLogbackConfigurator", 32 | "allDeclaredFields": true, 33 | "allDeclaredConstructors": true, 34 | "allDeclaredMethods": true, 35 | "allDeclaredClasses": true 36 | }, 37 | { 38 | "name": "ch.qos.logback.classic.pattern.DateConverter", 39 | "allDeclaredFields": true, 40 | "allDeclaredConstructors": true, 41 | "allDeclaredMethods": true, 42 | "allDeclaredClasses": true 43 | }, 44 | { 45 | "name": "ch.qos.logback.classic.pattern.LevelConverter", 46 | "allDeclaredFields": true, 47 | "allDeclaredConstructors": true, 48 | "allDeclaredMethods": true, 49 | "allDeclaredClasses": true 50 | }, 51 | { 52 | "name": "ch.qos.logback.classic.pattern.LineSeparatorConverter", 53 | "allDeclaredFields": true, 54 | "allDeclaredConstructors": true, 55 | "allDeclaredMethods": true, 56 | "allDeclaredClasses": true 57 | }, 58 | { 59 | "name": "ch.qos.logback.classic.pattern.LoggerConverter", 60 | "allDeclaredFields": true, 61 | "allDeclaredConstructors": true, 62 | "allDeclaredMethods": true, 63 | "allDeclaredClasses": true 64 | }, 65 | { 66 | "name": "ch.qos.logback.classic.pattern.MDCConverter", 67 | "allDeclaredFields": true, 68 | "allDeclaredConstructors": true, 69 | "allDeclaredMethods": true, 70 | "allDeclaredClasses": true 71 | }, 72 | { 73 | "name": "ch.qos.logback.classic.pattern.MessageConverter", 74 | "allDeclaredFields": true, 75 | "allDeclaredConstructors": true, 76 | "allDeclaredMethods": true, 77 | "allDeclaredClasses": true 78 | }, 79 | { 80 | "name": "ch.qos.logback.classic.pattern.NopThrowableInformationConverter", 81 | "allDeclaredFields": true, 82 | "allDeclaredConstructors": true, 83 | "allDeclaredMethods": true, 84 | "allDeclaredClasses": true 85 | }, 86 | { 87 | "name": "ch.qos.logback.core.pattern.ReplacingCompositeConverter", 88 | "allDeclaredFields": true, 89 | "allDeclaredConstructors": true, 90 | "allDeclaredMethods": true, 91 | "allDeclaredClasses": true 92 | }, 93 | { 94 | "name": "ch.qos.logback.classic.pattern.ThrowableProxyConverter", 95 | "allDeclaredFields": true, 96 | "allDeclaredConstructors": true, 97 | "allDeclaredMethods": true, 98 | "allDeclaredClasses": true 99 | }, 100 | { 101 | "name": "ch.qos.logback.classic.pattern.ThreadConverter", 102 | "allDeclaredFields": true, 103 | "allDeclaredConstructors": true, 104 | "allDeclaredMethods": true, 105 | "allDeclaredClasses": true 106 | }, 107 | { 108 | "name": "ch.qos.logback.core.rolling.helper.DateTokenConverter", 109 | "allDeclaredFields": true, 110 | "allDeclaredConstructors": true, 111 | "allDeclaredMethods": true, 112 | "allDeclaredClasses": true 113 | }, 114 | { 115 | "name": "ch.qos.logback.core.rolling.helper.IntegerTokenConverter", 116 | "allDeclaredFields": true, 117 | "allDeclaredConstructors": true, 118 | "allDeclaredMethods": true, 119 | "allDeclaredClasses": true 120 | }, 121 | { 122 | "name": "com.amazonaws.partitions.model.Partitions", 123 | "allPublicMethods": true, 124 | "allDeclaredConstructors": true 125 | }, 126 | { 127 | "name": "com.amazonaws.partitions.model.Partition", 128 | "allPublicMethods": true, 129 | "allDeclaredConstructors": true 130 | }, 131 | { 132 | "name": "com.amazonaws.partitions.model.Endpoint", 133 | "allPublicMethods": true, 134 | "allDeclaredConstructors": true 135 | }, 136 | { 137 | "name": "com.amazonaws.partitions.model.Region", 138 | "allPublicMethods": true, 139 | "allDeclaredConstructors": true 140 | }, 141 | { 142 | "name": "com.amazonaws.partitions.model.Service", 143 | "allPublicMethods": true, 144 | "allDeclaredConstructors": true 145 | }, 146 | { 147 | "name": "com.amazonaws.partitions.model.CredentialScope", 148 | "allPublicMethods": true, 149 | "allDeclaredConstructors": true 150 | }, 151 | { 152 | "name": "java.util.HashSet", 153 | "allPublicMethods": true, 154 | "allDeclaredConstructors": true 155 | }, 156 | { 157 | "name": "com.amazonaws.internal.config.InternalConfigJsonHelper", 158 | "allDeclaredFields": true, 159 | "allDeclaredConstructors": true, 160 | "allDeclaredMethods": true, 161 | "allDeclaredClasses": true 162 | }, 163 | { 164 | "name": "com.amazonaws.internal.config.SignerConfig", 165 | "allDeclaredFields": true, 166 | "allDeclaredConstructors": true, 167 | "allDeclaredMethods": true, 168 | "allDeclaredClasses": true 169 | }, 170 | { 171 | "name": "com.amazonaws.internal.config.SignerConfigJsonHelper", 172 | "allDeclaredFields": true, 173 | "allDeclaredConstructors": true, 174 | "allDeclaredMethods": true, 175 | "allDeclaredClasses": true 176 | }, 177 | { 178 | "name": "com.amazonaws.internal.config.HttpClientConfig", 179 | "allDeclaredFields": true, 180 | "allDeclaredConstructors": true, 181 | "allDeclaredMethods": true, 182 | "allDeclaredClasses": true 183 | }, 184 | { 185 | "name": "com.amazonaws.internal.config.HttpClientConfigJsonHelper", 186 | "allDeclaredFields": true, 187 | "allDeclaredConstructors": true, 188 | "allDeclaredMethods": true, 189 | "allDeclaredClasses": true 190 | }, 191 | { 192 | "name": "com.amazonaws.internal.config.HostRegexToRegionMappingJsonHelper", 193 | "allDeclaredFields": true, 194 | "allDeclaredConstructors": true, 195 | "allDeclaredMethods": true, 196 | "allDeclaredClasses": true 197 | }, 198 | { 199 | "name": "com.amazonaws.internal.config.JsonIndex", 200 | "allDeclaredFields": true, 201 | "allDeclaredConstructors": true, 202 | "allDeclaredMethods": true, 203 | "allDeclaredClasses": true 204 | }, 205 | { 206 | "name": "sun.security.ssl.SSLContextImpl$TLSContext", 207 | "allDeclaredFields": true, 208 | "allDeclaredConstructors": true, 209 | "allDeclaredMethods": true, 210 | "allDeclaredClasses": true 211 | }, 212 | { 213 | "name": "com.amazonaws.auth.AWS4Signer", 214 | "allDeclaredFields": true, 215 | "allDeclaredConstructors": true, 216 | "allDeclaredMethods": true, 217 | "allDeclaredClasses": true 218 | }, 219 | { 220 | "name": "com.sun.crypto.provider.HmacCore$HmacSHA256", 221 | "allDeclaredFields": true, 222 | "allDeclaredConstructors": true, 223 | "allDeclaredMethods": true, 224 | "allDeclaredClasses": true 225 | }, 226 | { 227 | "name": "org.apache.http.client.config.RequestConfig", 228 | "allDeclaredFields": true, 229 | "allDeclaredConstructors": true, 230 | "allDeclaredMethods": true, 231 | "allDeclaredClasses": true 232 | }, 233 | { 234 | "name": "org.apache.http.client.config.RequestConfig$Builder", 235 | "allDeclaredFields": true, 236 | "allDeclaredConstructors": true, 237 | "allDeclaredMethods": true, 238 | "allDeclaredClasses": true 239 | }, 240 | { 241 | "name": "sun.security.provider.X509Factory", 242 | "allDeclaredFields": true, 243 | "allDeclaredConstructors": true, 244 | "allDeclaredMethods": true, 245 | "allDeclaredClasses": true 246 | }, 247 | { 248 | "name": "sun.security.x509.AuthorityInfoAccessExtension", 249 | "allDeclaredFields": true, 250 | "allDeclaredConstructors": true, 251 | "allDeclaredMethods": true, 252 | "allDeclaredClasses": true 253 | }, 254 | { 255 | "name": "sun.security.x509.AuthorityKeyIdentifierExtension", 256 | "allDeclaredFields": true, 257 | "allDeclaredConstructors": true, 258 | "allDeclaredMethods": true, 259 | "allDeclaredClasses": true 260 | }, 261 | { 262 | "name": "sun.security.x509.BasicConstraintsExtension", 263 | "allDeclaredFields": true, 264 | "allDeclaredConstructors": true, 265 | "allDeclaredMethods": true, 266 | "allDeclaredClasses": true 267 | }, 268 | { 269 | "name": "sun.security.x509.CertificateIssuerExtension", 270 | "allDeclaredFields": true, 271 | "allDeclaredConstructors": true, 272 | "allDeclaredMethods": true, 273 | "allDeclaredClasses": true 274 | }, 275 | { 276 | "name": "sun.security.x509.CertificatePoliciesExtension", 277 | "allDeclaredFields": true, 278 | "allDeclaredConstructors": true, 279 | "allDeclaredMethods": true, 280 | "allDeclaredClasses": true 281 | }, 282 | { 283 | "name": "sun.security.x509.CRLDistributionPointsExtension", 284 | "allDeclaredFields": true, 285 | "allDeclaredConstructors": true, 286 | "allDeclaredMethods": true, 287 | "allDeclaredClasses": true 288 | }, 289 | { 290 | "name": "sun.security.x509.CRLNumberExtension", 291 | "allDeclaredFields": true, 292 | "allDeclaredConstructors": true, 293 | "allDeclaredMethods": true, 294 | "allDeclaredClasses": true 295 | }, 296 | { 297 | "name": "sun.security.x509.CRLReasonCodeExtension", 298 | "allDeclaredFields": true, 299 | "allDeclaredConstructors": true, 300 | "allDeclaredMethods": true, 301 | "allDeclaredClasses": true 302 | }, 303 | { 304 | "name": "sun.security.x509.DeltaCRLIndicatorExtension", 305 | "allDeclaredFields": true, 306 | "allDeclaredConstructors": true, 307 | "allDeclaredMethods": true, 308 | "allDeclaredClasses": true 309 | }, 310 | { 311 | "name": "sun.security.x509.ExtendedKeyUsageExtension", 312 | "allDeclaredFields": true, 313 | "allDeclaredConstructors": true, 314 | "allDeclaredMethods": true, 315 | "allDeclaredClasses": true 316 | }, 317 | { 318 | "name": "sun.security.x509.FreshestCRLExtension", 319 | "allDeclaredFields": true, 320 | "allDeclaredConstructors": true, 321 | "allDeclaredMethods": true, 322 | "allDeclaredClasses": true 323 | }, 324 | { 325 | "name": "sun.security.x509.InhibitAnyPolicyExtension", 326 | "allDeclaredFields": true, 327 | "allDeclaredConstructors": true, 328 | "allDeclaredMethods": true, 329 | "allDeclaredClasses": true 330 | }, 331 | { 332 | "name": "sun.security.x509.InvalidityDateExtension", 333 | "allDeclaredFields": true, 334 | "allDeclaredConstructors": true, 335 | "allDeclaredMethods": true, 336 | "allDeclaredClasses": true 337 | }, 338 | { 339 | "name": "sun.security.x509.IssuerAlternativeNameExtension", 340 | "allDeclaredFields": true, 341 | "allDeclaredConstructors": true, 342 | "allDeclaredMethods": true, 343 | "allDeclaredClasses": true 344 | }, 345 | { 346 | "name": "sun.security.x509.IssuingDistributionPointExtension", 347 | "allDeclaredFields": true, 348 | "allDeclaredConstructors": true, 349 | "allDeclaredMethods": true, 350 | "allDeclaredClasses": true 351 | }, 352 | { 353 | "name": "sun.security.x509.KeyUsageExtension", 354 | "allDeclaredFields": true, 355 | "allDeclaredConstructors": true, 356 | "allDeclaredMethods": true, 357 | "allDeclaredClasses": true 358 | }, 359 | { 360 | "name": "sun.security.x509.NameConstraintsExtension", 361 | "allDeclaredFields": true, 362 | "allDeclaredConstructors": true, 363 | "allDeclaredMethods": true, 364 | "allDeclaredClasses": true 365 | }, 366 | { 367 | "name": "sun.security.x509.NetscapeCertTypeExtension", 368 | "allDeclaredFields": true, 369 | "allDeclaredConstructors": true, 370 | "allDeclaredMethods": true, 371 | "allDeclaredClasses": true 372 | }, 373 | { 374 | "name": "sun.security.x509.OCSPNoCheckExtension", 375 | "allDeclaredFields": true, 376 | "allDeclaredConstructors": true, 377 | "allDeclaredMethods": true, 378 | "allDeclaredClasses": true 379 | }, 380 | { 381 | "name": "sun.security.x509.PolicyConstraintsExtension", 382 | "allDeclaredFields": true, 383 | "allDeclaredConstructors": true, 384 | "allDeclaredMethods": true, 385 | "allDeclaredClasses": true 386 | }, 387 | { 388 | "name": "sun.security.x509.PolicyMappingsExtension", 389 | "allDeclaredFields": true, 390 | "allDeclaredConstructors": true, 391 | "allDeclaredMethods": true, 392 | "allDeclaredClasses": true 393 | }, 394 | { 395 | "name": "sun.security.x509.PrivateKeyUsageExtension", 396 | "allDeclaredFields": true, 397 | "allDeclaredConstructors": true, 398 | "allDeclaredMethods": true, 399 | "allDeclaredClasses": true 400 | }, 401 | { 402 | "name": "sun.security.x509.SubjectAlternativeNameExtension", 403 | "allDeclaredFields": true, 404 | "allDeclaredConstructors": true, 405 | "allDeclaredMethods": true, 406 | "allDeclaredClasses": true 407 | }, 408 | { 409 | "name": "sun.security.x509.SubjectInfoAccessExtension", 410 | "allDeclaredFields": true, 411 | "allDeclaredConstructors": true, 412 | "allDeclaredMethods": true, 413 | "allDeclaredClasses": true 414 | }, 415 | { 416 | "name": "sun.security.x509.SubjectKeyIdentifierExtension", 417 | "allDeclaredFields": true, 418 | "allDeclaredConstructors": true, 419 | "allDeclaredMethods": true, 420 | "allDeclaredClasses": true 421 | }, 422 | { 423 | "name": "sun.security.x509.UnparseableExtension", 424 | "allDeclaredFields": true, 425 | "allDeclaredConstructors": true, 426 | "allDeclaredMethods": true, 427 | "allDeclaredClasses": true 428 | } 429 | ] -------------------------------------------------------------------------------- /samples/aws-lambda-java-dynamodb-native/src/main/resources/META-INF/native-image/io.redskap/aws-lambda-java-dynamodb-native/resource-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "resources": { 3 | "includes": [ 4 | { 5 | "pattern": "META-INF/services/.*" 6 | }, 7 | { 8 | "pattern": "com/amazonaws/partitions/endpoints.json" 9 | }, 10 | { 11 | "pattern": "com/amazonaws/internal/config/awssdk_config_default.json" 12 | }, 13 | { 14 | "pattern": "com/amazonaws/sdk/versionInfo.properties" 15 | } 16 | ] 17 | } 18 | } -------------------------------------------------------------------------------- /samples/aws-lambda-java-native/.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .gradle -------------------------------------------------------------------------------- /samples/aws-lambda-java-native/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | !**/src/main/**/build/ 5 | !**/src/test/**/build/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | bin/ 16 | !**/src/main/**/bin/ 17 | !**/src/test/**/bin/ 18 | 19 | ### IntelliJ IDEA ### 20 | .idea 21 | *.iws 22 | *.iml 23 | *.ipr 24 | out/ 25 | !**/src/main/**/out/ 26 | !**/src/test/**/out/ 27 | 28 | ### NetBeans ### 29 | /nbproject/private/ 30 | /nbbuild/ 31 | /dist/ 32 | /nbdist/ 33 | /.nb-gradle/ 34 | 35 | ### VS Code ### 36 | .vscode/ 37 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-native/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gradle:6.8.3-jdk11 as builder 2 | COPY --chown=gradle:gradle . /home/application 3 | WORKDIR /home/application 4 | RUN gradle clean shadowJar --no-daemon 5 | 6 | FROM amazon/aws-lambda-provided:al2.2021.03.22.18 as graalvm 7 | ENV LANG=en_US.UTF-8 8 | RUN yum install -y gcc gcc-c++ libc6-dev zlib1g-dev curl bash zlib zlib-devel zip tar gzip 9 | ENV GRAAL_VERSION 21.0.0.2 10 | ENV JDK_VERSION java11 11 | ENV GRAAL_FILENAME graalvm-ce-${JDK_VERSION}-linux-amd64-${GRAAL_VERSION}.tar.gz 12 | RUN curl -4 -L https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${GRAAL_VERSION}/${GRAAL_FILENAME} -o /tmp/${GRAAL_FILENAME} 13 | RUN tar -zxf /tmp/${GRAAL_FILENAME} -C /tmp \ 14 | && mv /tmp/graalvm-ce-${JDK_VERSION}-${GRAAL_VERSION} /usr/lib/graalvm 15 | RUN rm -rf /tmp/* 16 | CMD ["/usr/lib/graalvm/bin/native-image"] 17 | 18 | FROM graalvm 19 | COPY --from=builder /home/application/ /home/application/ 20 | WORKDIR /home/application 21 | ENV BUILT_JAR_NAME=aws-lambda-java-native-0.0.1-SNAPSHOT-all 22 | RUN /usr/lib/graalvm/bin/gu install native-image 23 | RUN /usr/lib/graalvm/bin/native-image --verbose -jar build/libs/${BUILT_JAR_NAME}.jar 24 | RUN mv ${BUILT_JAR_NAME} function 25 | RUN chmod 777 function 26 | RUN zip -j function.zip bootstrap function 27 | ENTRYPOINT ["bash"] -------------------------------------------------------------------------------- /samples/aws-lambda-java-native/bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -euo pipefail 3 | ./function -Xmx256m -Djava.library.path=$(pwd) -------------------------------------------------------------------------------- /samples/aws-lambda-java-native/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.github.johnrengelman.shadow' version '6.1.0' 3 | id 'com.bmuschko.docker-remote-api' version '6.7.0' 4 | id 'java' 5 | } 6 | 7 | import com.bmuschko.gradle.docker.tasks.container.* 8 | import com.bmuschko.gradle.docker.tasks.image.* 9 | 10 | group = 'io.redskap' 11 | version = '0.0.1-SNAPSHOT' 12 | sourceCompatibility = '11' 13 | 14 | repositories { 15 | mavenCentral() 16 | } 17 | 18 | dependencies { 19 | implementation 'io.redskap:aws-lambda-java-runtime:0.0.1' 20 | 21 | testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1' 22 | testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1' 23 | } 24 | 25 | test { 26 | useJUnitPlatform() 27 | } 28 | 29 | shadowJar { 30 | manifest { 31 | attributes 'Main-Class': 'io.redskap.lambda.runtime.sample.NativeApp' 32 | } 33 | } 34 | 35 | task buildNativeImage(type: DockerBuildImage) { 36 | inputDir = project.rootDir 37 | images.add('aws-lambda-java-native') 38 | } 39 | 40 | task createContainer(type: DockerCreateContainer) { 41 | dependsOn buildNativeImage 42 | targetImageId buildNativeImage.getImageId() 43 | hostConfig.autoRemove = true 44 | tty = true 45 | } 46 | 47 | task startContainer(type: DockerStartContainer) { 48 | dependsOn createContainer 49 | targetContainerId createContainer.getContainerId() 50 | } 51 | 52 | task copyNativePackageFromContainer(type: DockerCopyFileFromContainer) { 53 | dependsOn startContainer 54 | targetContainerId createContainer.getContainerId() 55 | hostPath = "${project.buildDir}/function.zip" 56 | remotePath = '/home/application/function.zip' 57 | } 58 | 59 | task stopNativeContainer(type: DockerStopContainer) { 60 | dependsOn copyNativePackageFromContainer 61 | targetContainerId createContainer.getContainerId() 62 | } 63 | 64 | task buildNative() { 65 | dependsOn stopNativeContainer 66 | } -------------------------------------------------------------------------------- /samples/aws-lambda-java-native/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/redskap/aws-lambda-java-runtime/27bc28a29d6384d1feb6f524697a25ac11a293b1/samples/aws-lambda-java-native/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /samples/aws-lambda-java-native/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-native/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-native/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-native/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'aws-lambda-java-native' 2 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-native/src/main/java/io/redskap/lambda/runtime/sample/APIGatewayRequestHandler.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.sample; 2 | 3 | import com.amazonaws.services.lambda.runtime.Context; 4 | import com.amazonaws.services.lambda.runtime.RequestHandler; 5 | import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; 6 | import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; 7 | 8 | import java.util.Collections; 9 | 10 | public class APIGatewayRequestHandler implements RequestHandler { 11 | @Override 12 | public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) { 13 | APIGatewayProxyResponseEvent apiGatewayProxyResponseEvent = new APIGatewayProxyResponseEvent(); 14 | apiGatewayProxyResponseEvent.setHeaders(Collections.singletonMap("test", input.getPath())); 15 | apiGatewayProxyResponseEvent.setStatusCode(200); 16 | return apiGatewayProxyResponseEvent; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-native/src/main/java/io/redskap/lambda/runtime/sample/IdentityRequestHandler.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.sample; 2 | 3 | import com.amazonaws.services.lambda.runtime.Context; 4 | import com.amazonaws.services.lambda.runtime.RequestHandler; 5 | 6 | public class IdentityRequestHandler implements RequestHandler { 7 | @Override 8 | public String handleRequest(String input, Context context) { 9 | return input; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /samples/aws-lambda-java-native/src/main/java/io/redskap/lambda/runtime/sample/NativeApp.java: -------------------------------------------------------------------------------- 1 | package io.redskap.lambda.runtime.sample; 2 | 3 | import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; 4 | import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; 5 | import io.redskap.lambda.runtime.LambdaRuntime; 6 | import io.redskap.lambda.runtime.RequestHandlerRegistration; 7 | 8 | import static java.util.Arrays.asList; 9 | 10 | public class NativeApp { 11 | public static void main(String[] args) { 12 | new LambdaRuntime(asList( 13 | new RequestHandlerRegistration<>(new APIGatewayRequestHandler(), APIGatewayProxyRequestEvent.class, APIGatewayProxyResponseEvent.class), 14 | new RequestHandlerRegistration<>(new IdentityRequestHandler(), String.class, String.class) 15 | )).run(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'aws-lambda-java-runtime' 2 | include 'aws-lambda-java-runtime' 3 | include ':samples:aws-lambda-java-native' 4 | include ':samples:aws-lambda-java-dynamodb-native' -------------------------------------------------------------------------------- /src-docs/.npmignore: -------------------------------------------------------------------------------- 1 | pids 2 | logs 3 | node_modules 4 | npm-debug.log 5 | coverage/ 6 | run 7 | dist 8 | .DS_Store 9 | .nyc_output 10 | .basement 11 | config.local.js 12 | basement_dist 13 | -------------------------------------------------------------------------------- /src-docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-lambda-java-runtime", 3 | "version": "0.0.1", 4 | "description": "", 5 | "main": "index.js", 6 | "authors": { 7 | "name": "Arnold Galovics", 8 | "email": "" 9 | }, 10 | "repository": "/aws-lambda-java-runtime", 11 | "scripts": { 12 | "dev": "vuepress dev src", 13 | "build": "vuepress build src" 14 | }, 15 | "license": "MIT", 16 | "devDependencies": { 17 | "@vuepress/plugin-google-analytics": "^1.8.2", 18 | "vuepress": "^1.8.2" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src-docs/src/.vuepress/config.js: -------------------------------------------------------------------------------- 1 | const { description } = require('../../package') 2 | 3 | module.exports = { 4 | base: '/aws-lambda-java-runtime/', 5 | dest: '../docs', 6 | title: 'AWS Lambda Java Runtime', 7 | description: description, 8 | head: [ 9 | ['meta', { name: 'theme-color', content: '#3eaf7c' }], 10 | ['meta', { name: 'apple-mobile-web-app-capable', content: 'yes' }], 11 | ['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'black' }] 12 | ], 13 | themeConfig: { 14 | repo: 'redskap/aws-lambda-java-runtime', 15 | editLinks: true, 16 | docsDir: 'src-docs/src', 17 | editLinkText: 'Help improve these docs!', 18 | lastUpdated: true, 19 | nav: [ 20 | { 21 | text: 'Author\'s blog', 22 | link: 'https://arnoldgalovics.com/', 23 | }, 24 | { 25 | text: 'Twitter', 26 | link: 'https://twitter.com/ArnoldGalovics', 27 | } 28 | ], 29 | sidebar: [ 30 | '/', 31 | '/troubleshooting/', 32 | '/changelog/', 33 | ] 34 | }, 35 | plugins: [ 36 | '@vuepress/plugin-back-to-top', 37 | '@vuepress/plugin-medium-zoom', 38 | ['@vuepress/plugin-google-analytics', { ga: "UA-78900346-3" }], 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /src-docs/src/.vuepress/enhanceApp.js: -------------------------------------------------------------------------------- 1 | export default ({ 2 | Vue, 3 | options, 4 | router, 5 | siteData 6 | }) => { 7 | } 8 | -------------------------------------------------------------------------------- /src-docs/src/.vuepress/styles/index.styl: -------------------------------------------------------------------------------- 1 | /** 2 | * Custom Styles here. 3 | * 4 | * ref:https://v1.vuepress.vuejs.org/config/#index-styl 5 | */ 6 | 7 | .home .hero img 8 | max-width 450px!important 9 | -------------------------------------------------------------------------------- /src-docs/src/.vuepress/styles/palette.styl: -------------------------------------------------------------------------------- 1 | /** 2 | * Custom palette here. 3 | * 4 | * ref:https://v1.vuepress.vuejs.org/zh/config/#palette-styl 5 | */ 6 | 7 | $accentColor = #3eaf7c 8 | $textColor = #2c3e50 9 | $borderColor = #eaecef 10 | $codeBgColor = #282c34 11 | 12 | $sidebarWidth = 25rem -------------------------------------------------------------------------------- /src-docs/src/changelog/README.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 0.0.2-SNAPSHOT 4 | TBD 5 | 6 | ## 0.0.1 7 | * Initial release 8 | 9 | Released at 2021-04-05 -------------------------------------------------------------------------------- /src-docs/src/index.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | Serverless computing is getting more and more popular. One of the cloud providers supporting 3 | a service like this is AWS, and the corresponding AWS Lambda service. 4 | 5 | Java is a great language to write scalable and maintainable applications. However, for 6 | serverless computing it was not the best choice because of slow cold-starts. Until now. 7 | 8 | With this customized runtime, you can speed up your Java Lambda functions. Instead of 9 | spinning up a full JVM in AWS Lambda, it's possible to use GraalVM and compile a standalone 10 | native executable and run it without any additional overhead. 11 | 12 | ## Quickstart 13 | For now, the quickstart can be found on my blog: [Tackling Java cold startup times on AWS Lambda with GraalVM](https://arnoldgalovics.com/tackling-java-cold-startup-times-on-aws-lambda-with-graalvm/). -------------------------------------------------------------------------------- /src-docs/src/troubleshooting/README.md: -------------------------------------------------------------------------------- 1 | # Troubleshooting 2 | ## The Lambda function is reporting Runtime.InvalidEntrypoint 3 | ### Symptom 4 | ```text 5 | { 6 | "errorMessage": "RequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f Error: fork/exec /var/task/bootstrap: no such file or directory", 7 | "errorType": "Runtime.InvalidEntrypoint" 8 | } 9 | 10 | START RequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f Version: $LATEST 11 | END RequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f 12 | REPORT RequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f Duration: 0.69 ms Billed Duration: 1 ms Memory Size: 128 MB Max Memory Used: 5 MB 13 | RequestId: 8ba2e00d-c988-4304-a84e-6bd8801c510f Error: fork/exec /var/task/bootstrap: no such file or directory 14 | Runtime.InvalidEntrypoint 15 | ``` 16 | ### Solution 17 | The `boostrap` file has CRLF instead of LF. Convert the line endings, and re-upload the package. 18 | 19 | ## Unable to create Proxy class 20 | ### Symptom 21 | ```text 22 | This indicates you are using an old version (< 4.5.8) of Apache http client. It is recommended to use http client version >= 4.5.9 to avoid the breaking change introduced in apache client 4.5.7 and the latency in exception handling. See https://github.com/aws/aws-sdk-java/issues/1919 for more information 23 | Exception in thread "main" com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.apache.http.conn.ConnectionRequest, interface com.amazonaws.http.conn.Wrapped] not found. Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image build time by specifying the list of interfaces that they implement. To define proxy classes use -H:DynamicProxyConfigurationFiles= and -H:DynamicProxyConfigurationResources= options. 24 | at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:87) 25 | at com.oracle.svm.reflect.proxy.DynamicProxySupport.getProxyClass(DynamicProxySupport.java:113) 26 | at java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:66) 27 | at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1006) 28 | at com.amazonaws.http.conn.ClientConnectionRequestFactory.wrap(ClientConnectionRequestFactory.java:45) 29 | at com.amazonaws.http.conn.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:78) 30 | at com.amazonaws.http.conn.$Proxy148.requestConnection(Unknown Source) 31 | at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:176) 32 | at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) 33 | at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) 34 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) 35 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) 36 | at com.amazonaws.http.apache.client.impl.SdkHttpClient.execute(SdkHttpClient.java:72) 37 | at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1331) 38 | at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1145) 39 | at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:802) 40 | at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:770) 41 | at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:744) 42 | at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:704) 43 | at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:686) 44 | at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:550) 45 | at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:530) 46 | at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.doInvoke(AmazonDynamoDBClient.java:6214) 47 | at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:6181) 48 | at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.executePutItem(AmazonDynamoDBClient.java:3793) 49 | at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.putItem(AmazonDynamoDBClient.java:3757) 50 | at com.arnoldgalovics.blog.app.TestRequestHandler.handleRequest(TestRequestHandler.java:24) 51 | at com.arnoldgalovics.blog.app.TestRequestHandler.handleRequest(TestRequestHandler.java:14) 52 | at io.redskap.lambda.runtime.internal.RequestHandlerInvoker.internalInvokeHandler(RequestHandlerInvoker.java:20) 53 | at io.redskap.lambda.runtime.internal.RequestHandlerInvoker.invokeHandler(RequestHandlerInvoker.java:10) 54 | at io.redskap.lambda.runtime.LambdaRuntime.run(LambdaRuntime.java:37) 55 | at com.arnoldgalovics.blog.app.JavaApp.main(JavaApp.java:21) 56 | END RequestId: 1fa87a52-03db-478f-9b7e-92ce62d445cd 57 | REPORT RequestId: 1fa87a52-03db-478f-9b7e-92ce62d445cd Duration: 169.66 ms Billed Duration: 181 ms Memory Size: 131 MB Max Memory Used: 32 MB Init Duration: 11.10 ms 58 | RequestId: 1fa87a52-03db-478f-9b7e-92ce62d445cd Error: Runtime exited with error: exit status 1 59 | Runtime.ExitError 60 | ``` 61 | ### Solution 62 | When building with GraalVM, the classes are pre-compiled into the executable. In case of interface-based runtime proxies, 63 | GraalVM should know which interfaces will be implemented by the proxy class. 64 | 65 | This can be configured via the `proxy-config.json` file within `META-INF/native-image/...` folder. 66 | 67 | Example configuration for the AWS DynamoDB SDK: 68 | ```json 69 | [ 70 | ["org.apache.http.conn.HttpClientConnectionManager", "org.apache.http.pool.ConnPoolControl", "com.amazonaws.http.conn.Wrapped"], 71 | ["org.apache.http.conn.ConnectionRequest", "com.amazonaws.http.conn.Wrapped"] 72 | ] 73 | ``` 74 | 75 | ## ClassNotFoundException during execution 76 | ### Symptom 77 | ```text 78 | START RequestId: 9a97e354-1089-47cf-8d47-1c48edd1e7d1 Version: $LATEST 79 | com.amazonaws.SdkClientException: Unable to calculate a request signature: Unable to calculate a request signature: No installed provider supports this key: javax.crypto.spec.SecretKeySpec 80 | at com.amazonaws.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:109) 81 | at com.amazonaws.auth.AWS4Signer.newSigningKey(AWS4Signer.java:639) 82 | at com.amazonaws.auth.AWS4Signer.deriveSigningKey(AWS4Signer.java:404) 83 | at com.amazonaws.auth.AWS4Signer.sign(AWS4Signer.java:253) 84 | at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1305) 85 | at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1145) 86 | at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:802) 87 | at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:770) 88 | at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:744) 89 | at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:704) 90 | at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:686) 91 | at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:550) 92 | at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:530) 93 | at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.doInvoke(AmazonDynamoDBClient.java:6214) 94 | at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:6181) 95 | at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.executePutItem(AmazonDynamoDBClient.java:3793) 96 | at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.putItem(AmazonDynamoDBClient.java:3757) 97 | at com.arnoldgalovics.blog.app.TestRequestHandler.handleRequest(TestRequestHandler.java:24) 98 | at com.arnoldgalovics.blog.app.TestRequestHandler.handleRequest(TestRequestHandler.java:14) 99 | at io.redskap.lambda.runtime.internal.RequestHandlerInvoker.internalInvokeHandler(RequestHandlerInvoker.java:20) 100 | at io.redskap.lambda.runtime.internal.RequestHandlerInvoker.invokeHandler(RequestHandlerInvoker.java:10) 101 | at io.redskap.lambda.runtime.LambdaRuntime.run(LambdaRuntime.java:37) 102 | at com.arnoldgalovics.blog.app.JavaApp.main(JavaApp.java:21) 103 | Caused by: com.amazonaws.SdkClientException: Unable to calculate a request signature: No installed provider supports this key: javax.crypto.spec.SecretKeySpec 104 | at com.amazonaws.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:132) 105 | at com.amazonaws.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:105) 106 | ... 22 more 107 | Caused by: java.security.InvalidKeyException: No installed provider supports this key: javax.crypto.spec.SecretKeySpec 108 | at javax.crypto.Mac.chooseProvider(Mac.java:392) 109 | at javax.crypto.Mac.init(Mac.java:435) 110 | at com.amazonaws.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:127) 111 | ... 23 more 112 | Caused by: java.security.NoSuchAlgorithmException: class configured for Mac (provider: SunJCE) cannot be found. 113 | at java.security.Provider$Service.getImplClass(Provider.java:1933) 114 | at java.security.Provider$Service.newInstance(Provider.java:1894) 115 | at javax.crypto.Mac.chooseProvider(Mac.java:365) 116 | ... 25 more 117 | Caused by: java.lang.ClassNotFoundException: com.sun.crypto.provider.HmacCore$HmacSHA256 118 | at com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:60) 119 | at java.lang.Class.forName(DynamicHub.java:1247) 120 | at java.security.Provider$Service.getImplClass(Provider.java:1918) 121 | ... 27 more 122 | END RequestId: 9a97e354-1089-47cf-8d47-1c48edd1e7d1 123 | REPORT RequestId: 9a97e354-1089-47cf-8d47-1c48edd1e7d1 Duration: 169.33 ms Billed Duration: 183 ms Memory Size: 131 MB Max Memory Used: 33 MB Init Duration: 13.63 ms 124 | ``` 125 | ### Solution 126 | In case of the application using any type of reflection to access a class, GraalVM will not know about it 127 | during AoT compilation. It needs to be told what these classes are in a file called `reflect-config.json` within the 128 | `META-INF/native-image/...` folder. 129 | 130 | Example configuration: 131 | ```json 132 | [ 133 | ... 134 | { 135 | "name": "com.sun.crypto.provider.HmacCore$HmacSHA256", 136 | "allDeclaredFields": true, 137 | "allDeclaredConstructors": true, 138 | "allDeclaredMethods": true, 139 | "allDeclaredClasses": true 140 | }, 141 | ... 142 | ] 143 | ``` --------------------------------------------------------------------------------