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.
To invoke a lambda function synchronously, use the invoke command, passing it the function name, the payload and the output filename as parameters. Copied! If you're on Windows , escape the double quotes of the --payload parameter, e.g. '{\"name\": \"John Smith\"}' .
stdout and stderr are basically files so can be used for arguments that expect one
aws lambda invoke --function-name GetErrorLambda --payload '{"body":"{\"Id\":[\"321\",\"123\"]}"}' /dev/stdout
though in this case the rest of the commands output will overlap with it, so probably better to cat it later anyways
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With