Ad space (banner)
AD

Got the fundamentals? A structured AWS course is a fast way to level up.

Find AWS courses on Udemy

Affiliate link. Costs you nothing extra.

☁️AWS Lessons
Lesson 37 / 41

Invoking a Function with aws lambda invoke

When you want to run a function on demand, use aws lambda invoke. It executes the function and captures its return value.

The syntax is aws lambda invoke function-name output-file, with --payload to pass input.

Running aws lambda invoke my-func executes it and returns a StatusCode of 200, with the function's own return value written to the output file.

A common stumble is reading the StatusCode as success. A 200 means Lambda ran the function; if the code threw, the error is in the response body.

In real work, it is how you test a function manually before wiring up its real trigger.

AWS
Try it (type this into the pseudo terminal)
aws lambda invoke my-func

🧑‍💻 You can type this command into the AWS pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)