Easy methods to Invoke an AWS Lambda from the CLI

0
9
Adv1


Adv2

If you wish to invoke an AWS Lambda out of your CLI, then the best choice is to have the AWS CLI put in.

Getting began with the AWS CLI – AWS Command Line Interface (amazon.com)

As soon as that is put in, you may invoke Lambdas as follows:

Setting your AWS Area

It is suggested to all the time set your AWS area in an setting variable referred to as AWS_REGION

export AWS_REGION=eu-west-1
aws lambda invoke --function-name YourFunction --region ${AWS_REGION} --cli-binary-format raw-in-base64-out --payload '{"keyName":"keyValue"}' response.json

Possibility 2 – If that you must use AWS CLI v1

aws lambda invoke --function-name YourFunction --region ${AWS_REGION} --payload $(echo '{"keyName":"keyValue"}') response.json

Logging

We specified a response.json on the finish of the above instructions. That is to get the output from the Lambda run.

You may also see detailed logs instantly within the CloudWatch group related to the above Lambda perform.

Adv3