I am building a AWS lambda function using Spring cloud, aws adapter and spring native. The lambda is fronted by a APIGateway HTTP API V2.0.
<java.version>11</java.version>
<spring-cloud.version>2021.0.2</spring-cloud.version>
<spring-native.version>0.11.4</spring-native.version>
<aws-lambda-events.version>3.9.0</aws-lambda-events.version>
<wrapper.version>1.0.27.RELEASE</wrapper.version>here
When I hit the API with the cloud function pointing to echo function, I get a response with the body of the request removed!
I setup below test to debug the issue. Found that the below highlighted code from
org.springframework.cloud.function.adapter.aws.AWSLambdaUtils
is causing the issue. I see that the highlighted line is removed in the 4X branch. Request to kindly guide how to incorporate that fix into my project while staying on the release version of the dependencies.
public static void main(String[] args) {
String message = "{\r\n"
+ " \"version\": \"2.0\",\r\n"
+ " \"routeKey\": \"POST /updatePet\",\r\n"
+ " \"rawPath\": \"/updatePet\",\r\n"
+ " \"rawQueryString\": \"\",\r\n"
+ " \"headers\": {\r\n"
+ " \"accept\": \"*/*\",\r\n"
+ " \"accept-encoding\": \"gzip, deflate, br\",\r\n"
+ " \"content-length\": \"77\",\r\n"
+ " \"content-type\": \"application/json\",\r\n"
+ " \"host\": \"XXXXXX.execute-api.ap-south-1.amazonaws.com\",\r\n"
+ " \"postman-token\": \"2004009f-2661-46ea-9a31-2d6be0bb9281\",\r\n"
+ " \"user-agent\": \"PostmanRuntime/7.29.0\",\r\n"
+ " \"x-amzn-trace-id\": \"Root=1-62823410-XXXXXXXXXXXXX\",\r\n"
+ " \"x-forwarded-for\": \"111.11.111.111, 111.111.111.111\",\r\n"
+ " \"x-forwarded-port\": \"443\",\r\n"
+ " \"x-forwarded-proto\": \"https\"\r\n"
+ " },\r\n"
+ " \"requestContext\": {\r\n"
+ " \"accountId\": \"123456733\",\r\n"
+ " \"apiId\": \"xxxxx\",\r\n"
+ " \"domainName\": \"xxxxxx.execute-api.ap-south-1.amazonaws.com\",\r\n"
+ " \"domainPrefix\": \"vaoo36b2l5\",\r\n"
+ " \"http\": {\r\n"
+ " \"method\": \"POST\",\r\n"
+ " \"path\": \"/updatePet\",\r\n"
+ " \"protocol\": \"HTTP/1.1\",\r\n"
+ " \"sourceIp\": \"1.1.1.1\",\r\n"
+ " \"userAgent\": \"PostmanRuntime/7.29.0\"\r\n"
+ " },\r\n"
+ " \"requestId\": \"SN0SoioabccwEJuQ=\",\r\n"
+ " \"routeKey\": \"POST /updatePet\",\r\n"
+ " \"stage\": \"$default\",\r\n"
+ " \"time\": \"16/May/2022:11:22:56 +0000\",\r\n"
+ " \"timeEpoch\": 1652700176657\r\n"
+ " },\r\n"
+ " \"body\": \"{\\r\\n\\\"id\\\":1,\\r\\n\\\"name\\\":\\\"toto\\\",\\r\\n\\\"type\\\":\\\"dog\\\",\\r\\n\\\"owner\\\":{\\\"name\\\":\\\"test\\\",\\\"age\\\":8}\\r\\n}\",\r\n"
+ " \"isBase64Encoded\": false\r\n"
+ "}";
Message<byte[]> msg = AWSLambdaUtils.generateMessage(message.getBytes(StandardCharsets.UTF_8), headers(), String.class, mapper());
var payload = new String(msg.getPayload(),StandardCharsets.UTF_8);
System.out.println("payload is"+payload);
}