I am using a Lambda Function within Step Functions. The function is written in Java. I want to pass multiple values similiar as in this question.
The code of the function looks like so:
public String handleRequest(S3Event event, Context context) {
//other code...
String eventJsonString = event.toJson();
JsonParser parser = new JsonParser();
JsonObject eventJson = parser.parse(eventJsonString).getAsJsonObject();
eventJson.addProperty("value1", value1);
eventJson.addProperty("value2", value2);
String output = eventJson.toString().replace("\\", "");
logger.log("output: " + output);
return output;
}
The log in CloudWatch is as expected:
output:
{
"Records": [
{
"awsRegion": "eu-west-1",
"eventName": "ObjectCreated:Put",
"eventSource": "aws:s3",
"eventTime": "1970-01-01T00:00:00.000Z",
"eventVersion": "2.0",
.
.
.
}
But when i go into the Step Function Console, i can see that the result was passed with escaped quotes:
"{\"Records\":[{\"awsRegion\":\"eu-west-1\",\"eventName\":\"ObjectCreated:Put\",\"eventSource\":\"aws:s3\",\"eventTime\":\"1970-01-01T00:00:00.000Z\",\"eventVersion\":\"2.0\",...}
This output can not be handled by the State Machine. I am not sure wether is this a only-java problem or also related to aws.
How can i pass the json-string with unescaped quotes, so it can be used by following components?