Building Serverless Python Web Services with Zappa
上QQ阅读APP看书,第一时间看更新

Invoking the function

The Lambda CLI provides a command to directly invoke the Lambda function:

$ aws lambda invoke --function-name <value> <outfile> 

Let's look at the parameters:

  • --function-name (required): This parameter asks for a Lambda function name
  • outfile (required): Here, you need to mention a filename where the returned output or response by the Lambda function will be stored

Here are other optional parameters available that you can list by the help command.

Let's invoke our recently created HelloWorldCLI function:

When we invoked the Lambda function, it immediately responded with a status code and the Lambda function returned the output data stored in the newly created lambda_output.txt file by the lambda invoke command.