Thursday, May 25, 2023
HomeSoftware EngineeringEasy methods to Invoke an AWS Lambda from the CLI

Easy methods to Invoke an AWS Lambda from the CLI


If you wish to invoke an AWS Lambda out of your CLI, then the most suitable 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’ll be able to invoke Lambdas as follows:

Setting your AWS Area

It’s endorsed to at all times 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

Choice 2 – If it is advisable 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 as well see detailed logs instantly within the CloudWatch group related to the above Lambda operate.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments