|
1 | 1 | # AWS Lambda Java Support Libraries
|
2 |
| -Interface definitions for Java code running on the AWS Lambda platform. |
| 2 | +Key libraries for running Java on the AWS Lambda platform. |
3 | 3 |
|
4 | 4 | For issues and questions, you can start with our [FAQ](https://aws.amazon.com/lambda/faqs/)
|
5 |
| - and the [AWS forums](https://forums.aws.amazon.com/forum.jspa?forumID=186) |
| 5 | +and the AWS questions and answer site [re:Post](https://repost.aws/tags/TA5uNafDy2TpGNjidWLMSxDw/aws-lambda) |
6 | 6 |
|
7 |
| -To get started writing AWS Lambda functions in Java, check out the [official documentation](http://docs.aws.amazon.com/lambda/latest/dg/java-gs.html). |
| 7 | +To get started writing Lambda functions in Java, check out the official [developer guide](https://docs.aws.amazon.com/lambda/latest/dg/lambda-java.html). |
8 | 8 |
|
9 |
| -# Disclaimer of use |
| 9 | +For information on how to optimize your functions watch the re:Invent talk [Optimize your Java application on AWS Lambda](https://www.youtube.com/watch?v=sVJOJUD0fhQ). |
10 | 10 |
|
11 |
| -Each of the supplied packages should be used without modification. Removing |
12 |
| -dependencies, adding conflicting dependencies, or selectively including classes |
13 |
| -from the packages can result in unexpected behavior. |
| 11 | +## Core Java Lambda interfaces - aws-lambda-java-core |
14 | 12 |
|
15 |
| -# Release Notes |
| 13 | +This package defines the Lambda [Context](http://docs.aws.amazon.com/lambda/latest/dg/java-context-object.html) object |
| 14 | +as well as [interfaces](http://docs.aws.amazon.com/lambda/latest/dg/java-handler-using-predefined-interfaces.html) that Lambda accepts. |
16 | 15 |
|
17 |
| -Check out the per-module release notes: |
18 |
| -- [aws-lambda-java-core](aws-lambda-java-core/RELEASE.CHANGELOG.md) |
19 |
| -- [aws-lambda-java-events](aws-lambda-java-events/RELEASE.CHANGELOG.md) |
20 |
| -- [aws-lambda-java-events-sdk-transformer](aws-lambda-java-events-sdk-transformer/RELEASE.CHANGELOG.md) |
21 |
| -- [aws-lambda-java-log4j2](aws-lambda-java-log4j2/RELEASE.CHANGELOG.md) |
22 |
| -- [aws-lambda-java-runtime-interface-client](aws-lambda-java-runtime-interface-client/RELEASE.CHANGELOG.md) |
23 |
| -- [aws-lambda-java-serialization](aws-lambda-java-serialization/RELEASE.CHANGELOG.md) |
24 |
| -- [aws-lambda-java-test](aws-lambda-java-tests/RELEASE.CHANGELOG.md) |
| 16 | +- [Release Notes](aws-lambda-java-core/RELEASE.CHANGELOG.md) |
25 | 17 |
|
26 |
| -# Where to get packages |
27 |
| -___ |
| 18 | +Example request handler |
| 19 | + |
| 20 | +```java |
| 21 | +public class Handler implements RequestHandler<Map<String, String>, String>{ |
| 22 | + @Override |
| 23 | + public String handleRequest(Map<String, String> event, Context context) { |
| 24 | + |
| 25 | + } |
| 26 | +} |
| 27 | +``` |
28 | 28 |
|
29 |
| -[Maven](https://maven.apache.org) |
| 29 | +Example request stream handler |
| 30 | + |
| 31 | +```java |
| 32 | +public class HandlerStream implements RequestStreamHandler { |
| 33 | + @Override |
| 34 | + public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException { |
| 35 | + |
| 36 | + } |
| 37 | +} |
| 38 | +``` |
30 | 39 |
|
31 | 40 | ```xml
|
32 | 41 | <dependency>
|
33 |
| - <groupId>com.amazonaws</groupId> |
34 |
| - <artifactId>aws-lambda-java-core</artifactId> |
35 |
| - <version>1.2.1</version> |
36 |
| -</dependency> |
37 |
| -<dependency> |
38 |
| - <groupId>com.amazonaws</groupId> |
39 |
| - <artifactId>aws-lambda-java-events</artifactId> |
40 |
| - <version>3.11.0</version> |
41 |
| -</dependency> |
42 |
| -<dependency> |
43 |
| - <groupId>com.amazonaws</groupId> |
44 |
| - <artifactId>aws-lambda-java-events-sdk-transformer</artifactId> |
45 |
| - <version>3.1.0</version> |
46 |
| -</dependency> |
47 |
| -<dependency> |
48 |
| - <groupId>com.amazonaws</groupId> |
49 |
| - <artifactId>aws-lambda-java-log4j2</artifactId> |
50 |
| - <version>1.5.1</version> |
51 |
| -</dependency> |
52 |
| -<dependency> |
53 |
| - <groupId>com.amazonaws</groupId> |
54 |
| - <artifactId>aws-lambda-java-runtime-interface-client</artifactId> |
55 |
| - <version>2.1.1</version> |
56 |
| -</dependency> |
57 |
| -<dependency> |
58 |
| - <groupId>com.amazonaws</groupId> |
59 |
| - <artifactId>aws-lambda-java-tests</artifactId> |
60 |
| - <version>1.1.1</version> |
61 |
| - <scope>test</scope> |
| 42 | + <groupId>com.amazonaws</groupId> |
| 43 | + <artifactId>aws-lambda-java-core</artifactId> |
| 44 | + <version>1.2.1</version> |
62 | 45 | </dependency>
|
63 | 46 | ```
|
64 | 47 |
|
65 |
| -[Gradle](https://gradle.org) |
| 48 | +## Java objects of Lambda event sources - aws-lambda-java-events |
66 | 49 |
|
67 |
| -```groovy |
68 |
| -'com.amazonaws:aws-lambda-java-core:1.2.1' |
69 |
| -'com.amazonaws:aws-lambda-java-events:3.11.0' |
70 |
| -'com.amazonaws:aws-lambda-java-events-sdk-transformer:3.1.0' |
71 |
| -'com.amazonaws:aws-lambda-java-log4j2:1.5.1' |
72 |
| -'com.amazonaws:aws-lambda-java-runtime-interface-client:2.1.1' |
73 |
| -'com.amazonaws:aws-lambda-java-tests:1.1.1' |
74 |
| -``` |
| 50 | +This package defines [event sources](http://docs.aws.amazon.com/lambda/latest/dg/intro-invocation-modes.html) that Lambda natively accepts. |
| 51 | +See the [documentation](aws-lambda-java-events/README.md) for a list of currently supported event sources. |
| 52 | +Using this library you can have Java objects which represent event sources. |
75 | 53 |
|
76 |
| -[Leiningen](http://leiningen.org) |
| 54 | +For example an SQS event: |
77 | 55 |
|
78 |
| -```clojure |
79 |
| -[com.amazonaws/aws-lambda-java-core "1.2.1"] |
80 |
| -[com.amazonaws/aws-lambda-java-events "3.11.0"] |
81 |
| -[com.amazonaws/aws-lambda-java-events-sdk-transformer "3.1.0"] |
82 |
| -[com.amazonaws/aws-lambda-java-log4j2 "1.5.1"] |
83 |
| -[com.amazonaws/aws-lambda-java-runtime-interface-client "2.1.1"] |
84 |
| -[com.amazonaws/aws-lambda-java-tests "1.1.1"] |
| 56 | +```java |
| 57 | +import com.amazonaws.services.lambda.runtime.events.SQSEvent; |
| 58 | + |
| 59 | +public class SqsHandler implements RequestHandler<SQSEvent, String> { |
| 60 | + |
| 61 | + @Override |
| 62 | + public String handleRequest(SQSEvent event, Context context) { |
| 63 | + |
| 64 | + } |
| 65 | +} |
85 | 66 | ```
|
86 | 67 |
|
87 |
| -[sbt](http://www.scala-sbt.org) |
| 68 | +- [Release Notes](aws-lambda-java-events/RELEASE.CHANGELOG.md) |
88 | 69 |
|
89 |
| -```scala |
90 |
| -"com.amazonaws" % "aws-lambda-java-core" % "1.2.1" |
91 |
| -"com.amazonaws" % "aws-lambda-java-events" % "3.11.0" |
92 |
| -"com.amazonaws" % "aws-lambda-java-events-sdk-transformer" % "3.1.0" |
93 |
| -"com.amazonaws" % "aws-lambda-java-log4j2" % "1.5.1" |
94 |
| -"com.amazonaws" % "aws-lambda-java-runtime-interface-client" % "2.1.1" |
95 |
| -"com.amazonaws" % "aws-lambda-java-tests" % "1.1.1" |
| 70 | +```xml |
| 71 | +<dependency> |
| 72 | + <groupId>com.amazonaws</groupId> |
| 73 | + <artifactId>aws-lambda-java-events</artifactId> |
| 74 | + <version>3.11.0</version> |
| 75 | +</dependency> |
96 | 76 | ```
|
97 | 77 |
|
98 |
| -# Using aws-lambda-java-core |
| 78 | +## Java Lambda JUnit Support - aws-lambda-java-tests |
99 | 79 |
|
100 |
| -This package defines the Lambda [Context](http://docs.aws.amazon.com/lambda/latest/dg/java-context-object.html) object |
101 |
| - as well as [interfaces](http://docs.aws.amazon.com/lambda/latest/dg/java-handler-using-predefined-interfaces.html) that Lambda accepts. |
| 80 | +This package provides utils to ease Lambda Java testing. It uses the same Lambda serialisation logic and `aws-lambda-java-events` to inject events in your JUnit tests. |
| 81 | + |
| 82 | +- [Release Notes](aws-lambda-java-tests/RELEASE.CHANGELOG.md) |
102 | 83 |
|
103 |
| -# Using aws-lambda-java-events |
| 84 | +```java |
| 85 | +@ParameterizedTest |
| 86 | +@Event(value = "sqs/sqs_event.json", type = SQSEvent.class) |
| 87 | +public void testInjectSQSEvent(SQSEvent event) { |
| 88 | + ... |
| 89 | +} |
| 90 | +``` |
104 | 91 |
|
105 |
| -This package defines [event sources](http://docs.aws.amazon.com/lambda/latest/dg/intro-invocation-modes.html) that AWS Lambda natively accepts. |
106 |
| -See the [documentation](aws-lambda-java-events/README.md) for more information. |
| 92 | +```xml |
| 93 | +<dependency> |
| 94 | + <groupId>com.amazonaws</groupId> |
| 95 | + <artifactId>aws-lambda-java-tests</artifactId> |
| 96 | + <version>1.1.1</version> |
| 97 | + <scope>test</scope> |
| 98 | +</dependency> |
| 99 | +``` |
107 | 100 |
|
108 |
| -# Using aws-lambda-java-events-sdk-transformer |
| 101 | +## aws-lambda-java-events-sdk-transformer |
109 | 102 |
|
110 | 103 | This package provides helper classes/methods to use alongside `aws-lambda-java-events` in order to transform
|
111 |
| - Lambda input event model objects into SDK-compatible output model objects. |
| 104 | +Lambda input event model objects into SDK-compatible output model objects. |
112 | 105 | See the [documentation](aws-lambda-java-events-sdk-transformer/README.md) for more information.
|
113 | 106 |
|
114 |
| -# Using aws-lambda-java-log4j2 |
| 107 | +- [Release Notes](aws-lambda-java-events-sdk-transformer/RELEASE.CHANGELOG.md) |
115 | 108 |
|
116 |
| -This package defines the Lambda adapter to use with log4j version 2. |
| 109 | +```xml |
| 110 | +<dependency> |
| 111 | + <groupId>com.amazonaws</groupId> |
| 112 | + <artifactId>aws-lambda-java-events-sdk-transformer</artifactId> |
| 113 | + <version>3.1.0</version> |
| 114 | +</dependency> |
| 115 | +``` |
| 116 | + |
| 117 | +## Java Lambda Log4J2 support - aws-lambda-java-log4j2 |
| 118 | + |
| 119 | +This package defines the Lambda adapter to use with Log4J version 2. |
117 | 120 | See the [README](aws-lambda-java-log4j2/README.md) or the [official documentation](http://docs.aws.amazon.com/lambda/latest/dg/java-logging.html#java-wt-logging-using-log4j) for information on how to use the adapter.
|
118 | 121 |
|
119 |
| -# Using aws-lambda-java-runtime-interface-client |
| 122 | +- [Release Notes](aws-lambda-java-log4j2/RELEASE.CHANGELOG.md) |
| 123 | + |
| 124 | +```xml |
| 125 | +<dependency> |
| 126 | + <groupId>com.amazonaws</groupId> |
| 127 | + <artifactId>aws-lambda-java-log4j2</artifactId> |
| 128 | + <version>1.5.1</version> |
| 129 | +</dependency> |
| 130 | +``` |
| 131 | + |
| 132 | +## Java implementation of the Runtime Interface Client API - aws-lambda-java-runtime-interface-client |
120 | 133 |
|
121 | 134 | This package defines the Lambda Java Runtime Interface Client package, a Lambda Runtime component that starts the runtime and interacts with the Runtime API - i.e., it calls the API for invocation events, starts the function code, calls the API to return the response.
|
122 | 135 | The purpose of this package is to allow developers to deploy their applications in Lambda under the form of Container Images. See the [README](aws-lambda-java-runtime-interface-client/README.md) for information on how to use the library.
|
123 | 136 |
|
124 |
| -# Using aws-lambda-java-serialization |
| 137 | +- [Release Notes](aws-lambda-java-runtime-interface-client/RELEASE.CHANGELOG.md) |
| 138 | + |
| 139 | +```xml |
| 140 | +<dependency> |
| 141 | + <groupId>com.amazonaws</groupId> |
| 142 | + <artifactId>aws-lambda-java-runtime-interface-client</artifactId> |
| 143 | + <version>2.1.1</version> |
| 144 | +</dependency> |
| 145 | +``` |
| 146 | + |
| 147 | +## Java Lambda provided serialization support - aws-lambda-java-serialization |
125 | 148 |
|
126 |
| -This package defines the Lambda serialization logic using in the aws-lambda-java-runtime-client library. It has no current standalone usage. |
| 149 | +This package defines the Lambda serialization logic using in the `aws-lambda-java-runtime-client` library. It has no current standalone usage. |
127 | 150 |
|
128 |
| -# Using aws-lambda-java-tests |
| 151 | +- [Release Notes](aws-lambda-java-serialization/RELEASE.CHANGELOG.md) |
129 | 152 |
|
130 |
| -This package provides utils to ease Lambda Java testing. Used with `aws-lambda-java-serialization` and `aws-lambda-java-events` to inject events in your JUnit tests. |
| 153 | +```xml |
| 154 | +<dependency> |
| 155 | + <groupId>com.amazonaws</groupId> |
| 156 | + <artifactId>aws-lambda-java-serialization</artifactId> |
| 157 | + <version>1.0.0</version> |
| 158 | +</dependency> |
| 159 | +``` |
| 160 | + |
| 161 | +## Disclaimer of use |
| 162 | + |
| 163 | +Each of the supplied packages should be used without modification. Removing |
| 164 | +dependencies, adding conflicting dependencies, or selectively including classes |
| 165 | +from the packages can result in unexpected behavior. |
0 commit comments