I have created aws lambda function in .net core and deployed. I have tried executing function in aws console with test case and its working. but i am not able achieve the same with cli command
aws lambda invoke --function-name "mylambda" --log-type Tail --payload file://D:/Files/lamdainputfile.json file://D:/Files/response.txt
i got getting error with cli command
An error occurred (InvalidRequestContentException) when calling the Invoke operation: Could not parse request body into json: Unexpected character ((CTRL-CHAR, code 138)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: (byte[])"�zn�]t�zn�m�"; line: 1, column: 2]
I tried passing json
aws lambda invoke --function-name "mylambda" --log-type Tail --payload "{'input1':'100', 'input2':'200'}" file://D:/Files/response.txt
but it's not working
This lambda function is executing aws console with test case and giving correct result. I have added same input in local json file and tried with cli command.
Json input:
{
"input1": "100",
"input2": "200"
}
EDIT:
After correction in inline json i am getting error for output file
Unknown options: file://D:/Files/response.txt
is there any command to print output in cli only?
The documentation is not updated from the cli version 1. For the aws cli version 2 we need to base64 encode the payload.
Mac:
payload=`echo '{"input1": 100, "input2": 200 }' | openssl base64`
aws lambda invoke --function-name myfunction --payload "$payload" SomeOutFile &