Skip to content

How to Invoke an AWS Lambda from the CLI

If you want to invoke an AWS Lambda from your CLI, then the best option is to have the AWS CLI installed.

Getting started with the AWS CLI – AWS Command Line Interface (

Once this is installed, you can invoke Lambdas as follows:

Setting your AWS Region

It is recommended to always set your AWS region in an environment variable called AWS_REGION

export AWS_REGION=eu-west-1
Code language: Bash (bash)

Option 1 – Recommended with AWS CLI v2

aws lambda invoke --function-name YourFunction --region ${AWS_REGION} --cli-binary-format raw-in-base64-out --payload '{"keyName":"keyValue"}' response.json
Code language: Bash (bash)

Option 2 – If you need to use AWS CLI v1

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


We specified a response.json at the end of the above commands. This is to get the output from the Lambda run.

You can also see detailed logs directly in the CloudWatch group associated to the above Lambda function.

See also  How to Fix String Casing in Python
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x