D

AWS Lambda

Lambda commands for invoking, deploying and debugging serverless functions.

Updated 2026-09-03

On this page

Listing & Inspecting

aws lambda list-functions

Lists Lambda functions in the current region.

aws lambda get-function --function-name my-function

Shows a function's configuration, code location, and current state.

aws lambda get-function-configuration --function-name my-function

Shows just the configuration — memory, timeout, env vars, runtime — without the code download URL.

Invoking

aws lambda invoke --function-name my-function --payload '{"key":"value"}' response.json

Invokes a function synchronously with a JSON payload, writing its response to a local file.

aws lambda invoke --function-name my-function --invocation-type Event response.json

Invokes asynchronously — returns immediately with a 202, without waiting for the function to finish.

cat response.json

Views the invocation result saved by a previous invoke command.

Deploying Code

zip -r function.zip .

Packages a function's code and dependencies into the zip format Lambda expects.

aws lambda update-function-code --function-name my-function --zip-file fileb://function.zip

Deploys new code to an existing function without changing its configuration.

aws lambda update-function-configuration --function-name my-function --timeout 30 --memory-size 512

Updates a function's timeout or memory allocation without touching its code.

aws lambda publish-version --function-name my-function

Publishes an immutable, numbered version of the function's current code and config — the basis for safely pointing an alias at a specific known-good version.

Environment Variables

aws lambda update-function-configuration --function-name my-function --environment "Variables={LOG_LEVEL=debug}"

Sets environment variables available to the function at runtime.

Don't put secrets directly in environment variables

Lambda environment variables are visible to anyone with read access to the function's configuration. For actual secrets, store them in Secrets Manager or Parameter Store and fetch them at cold start instead.

Logs

aws logs tail /aws/lambda/my-function --follow

Streams a function's CloudWatch Logs live — the fastest way to watch invocations as they happen.

aws logs tail /aws/lambda/my-function --since 1h

Shows logs from the last hour without streaming.

See AWS Lambda Handler Error for a step-by-step debugging sequence.

Official documentation

Related