Invalid base64 error Lambda AWS CLI

· Thomas Taylor

The Invalid base64 error occurs when invoking a lambda from the AWS CLI because the default --payload parameter expects base64 encoding.

1aws lambda invoke --function-name test --payload '{"movie": "John Wick"}' response.json

Error output:

1Invalid base64: "{"movie": "John Wick"}"

Solve Invalid base64 lambda invoke error

To solve the Invalid base64 error, supply the --cli-binary-format parameter with the value raw-in-base64-out:

1aws lambda invoke --function-name test --cli-binary-format raw-in-base64-out --payload '{"movie": "John Wick"}' response.json


2	"StatusCode": 200,
3	"ExecutedVersion": "$LATEST"

Invoke a lambda using a file

A user may opt to supply a .json file:

2	"movie": "John Wick"
1aws lambda invoke --function-name test --cli-binary-format raw-in-base64-out --payload file://request.json response.json

#Aws   #Aws-Cli  

Reply to this post by email ↪