5.2 KiB
Environment
The base images strive to provide the same environment that AWS provides to Lambda functions. This page describes it and any incompatibilities between AWS Lambda and Dockerized Lambda.
Request/Response
Functions has sync/async communication with Request/Response workflows.
- sync: returns the result as the body of the response
- async: returns the task id in the body of the response as a json
The context.succeed() will not do anything with result
on node.js, nor will returning anything from a Python function.
Paths
We do not make any compatibility efforts towards running your lambda function in the same working directory as it would run on AWS. If your function makes such assumptions, please rewrite it.
nodejs
- node.js version 0.10.42
- ImageMagick version 6.9.3 and nodejs wrapper 6.9.3
- aws-sdk version 2.2.12
Event
Payloads MUST be a valid JSON object literal.
Context object
- context.fail() does not currently truncate error logs.
context.functionNameis of the form of a docker image, for exampleusername/test-function.context.functionVersionis always the string"$LATEST".context.invokedFunctionArnis not supported. Value is empty string.context.memoryLimitInMBdoes not reflect reality. Value is always256.context.awsRequestIdreflects the environment variableTASK_ID. On local runs fromfntool this is a UUID. On Functions server this is the task ID.logGroupNameandlogStreamNameare empty strings.identityandclientContextare alwaysnull.
Exceptions
If your handler throws an exception, we only log the error message. There is no
v8::CallSite compatible stack trace yet.
Python 2.7
Event
Event is always a __dict__ and the payload MUST be a valid JSON object
literal.
Context object
context.functionNameis of the form of a docker image, for exampleusername/test-function.context.functionVersionis always the string"$LATEST".context.invokedFunctionArnisNone.context.awsRequestIdreflects the environment variableTASK_IDwhich is set to the task ID on Functions. If TASK_ID is empty, a new UUID is used.logGroupName,logStreamName,identityandclientContextareNone.
Exceptions
If your Lambda function throws an Exception, it will not currently be logged as a JSON object with trace information.
Java 8
- OpenJDK Java Runtime 1.8.0
The Java8 runtime is significantly lacking at this piont and we do not recommend using it.
Handler types
There are some restrictions on the handler types supported.
Only a void return type is allowed
Since Lambda does not support request/response invocation, we explicitly prohibit a non-void return type on the handler.
JSON parse error stack differences
AWS uses the Jackson parser, this project uses the GSON parser. So JSON parse errors will have different traces.
Single item vs. List
Given a list handler like:
public static void myHandler(List<Double> l) {
// ...
}
If the payload is a single number, AWS Lambda will succeed and pass the handler a list with a single item. This project will raise an exception.
Collections of POJOs
This project cannot currently deserialize a List or Map containing POJOs. For example:
public class Handler {
public static MyPOJO {
private String attribute;
public void setAttribute(String a) {
attribute = a;
}
public String getAttribute() {
return attribute;
}
}
public static void myHandler(List<MyPOJO> l) {
// ...
}
}
This handler invoked with the below event will fail!
[{ "attribute": "value 1"}, { "attribute": "value 2" }]
Leveraging predefined types is not supported
Using the types in aws-lambda-java-core to implement handlers is
untested and unsupported right now. While the package is available in your
function, we have not tried it out.
Logging
The log4j and LambdaLogger styles that log to CloudWatch are not supported.
Context object
context.getFunctionName()returns a String of the form of a docker image, for exampleusername/test-function.context.getFunctionVersion()is always the string"$LATEST".context.getAwsRequestId()reflects the environment variableTASK_IDwhich is set to the task ID on Functions. If TASK_ID is empty, a new UUID is used.getInvokedFunctionArn(),getLogGroupName(),getLogStreamName(),getIdentity(),getClientContext(),getLogger()returnnull.