Invoking aws lambda without output file

穿精又带淫゛_ 提交于 2019-12-07 03:01:17

问题


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.


回答1:


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




回答2:


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




回答3:


I use following command:

aws lambda invoke --function-name name --payload '{...}' /dev/stdout 1>/dev/null

The idea is redirect command output to stderr and the function result to stdout



来源:https://stackoverflow.com/questions/47675032/invoking-aws-lambda-without-output-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!