Search code examples
amazon-web-servicesaws-lambdaaws-cli

Invoking aws lambda without output file


I'm trying to invoke a lambda on AWS using CLI:

aws lambda invoke --function-name GetErrorLambda --payload '{"body":"{\"Id\":[\"321\",\"123\"]}"}' \output.

I would like to know if there's a way to print the output on the cli instead of create a file.

Thanks in advance.


Solution

  • It's not possible to output directly to the terminal after invoking a lambda function. This is likely by design as the output could easily be greater than the buffer size for a window.

    A simple workaround would be to simply 'cat' out the contents of the output file following the cli command like so:

    aws lambda invoke --function-name GetErrorLambda --payload '{"body":"{\"Id\":[\"321\",\"123\"]}"}' \output. && cat outputFileName.txt