0

I am new to lambda, succeeded in creating lambda functions through console and triggered them. but when i am trying to invoke them using AWS CLI, i am facing issues.

my lambda function (python) is simple and just prints the input arguments and tested successfully in console.

i am calling like below in cli from a windows machine,

aws lambda invoke --function-name testfn --invocation-type RequestResponse --payload '{"a":"b"}' outfile.txt

the error says - Invalid base64: "'{a:b}'"

But if i give an empty payload like -

aws lambda invoke --function-name testfn --invocation-type RequestResponse --payload '{}' outfile.txt

it is getting succceded with below output.

{
    "StatusCode": 200,
    "ExecutedVersion": "$LATEST"
}

So what is going wrong with my payload? Please help.

What does this error mean ? Invalid base64: "'{a:b}'"

I had also tried giving payload from a json file and passing that file with exact path in the command, still same error.

Marcin
  • 215,873
  • 14
  • 235
  • 294
santhosh
  • 439
  • 8
  • 17
  • Yes, this is what I am looking for.. thanks a ton. In my case I had to use a seperate json file along with the solution provided in the link for payload. – santhosh May 27 '20 at 15:36

1 Answers1

2

It means that the payload should be base64.

This requirement is one of the breaking changes in AWS CLI v2:

invoke payload is of type blob. In AWS CLI v2:

By default, the AWS CLI version 2 now passes all binary input and binary output parameters as base64-encoded strings. A parameter that requires binary input has its type specified as blob (binary large object) in the documentation.

Marcin
  • 215,873
  • 14
  • 235
  • 294