LinuxCommandLibrary

aws-lambda

Manage AWS Lambda functions

TLDR

Run a function

$ aws lambda invoke --function-name [name] [path/to/response.json]
copy

Run a function with an input payload in JSON format
$ aws lambda invoke --function-name [name] --payload [json] [path/to/response.json]
copy

List functions
$ aws lambda list-functions
copy

Display the configuration of a function
$ aws lambda get-function-configuration --function-name [name]
copy

List function aliases
$ aws lambda list-aliases --function-name [name]
copy

Display the reserved concurrency configuration for a function
$ aws lambda get-function-concurrency --function-name [name]
copy

List which AWS services can invoke the function
$ aws lambda get-policy --function-name [name]
copy

SYNOPSIS

aws lambda [options] [arguments]

Common Subcommands:
aws lambda create-function [--function-name ] [--runtime ] [--role ] ...
aws lambda update-function-code [--function-name ] [--zip-file ] ...
aws lambda invoke [--function-name ] [--payload ] [--invocation-type ] ...
aws lambda list-functions [--max-items ] ...
aws lambda delete-function [--function-name ] ...

General AWS CLI Options (applicable to aws lambda subcommands):
aws ... [--region ] [--output ] [--profile ] ...

PARAMETERS

--region
    Specifies the AWS region to send the request to (e.g., us-east-1).

--output
    Determines the output format (e.g., json, text, table).

--profile
    Uses a specific named profile from your credentials file.

--endpoint-url
    Overrides the default service endpoint URL.

--cli-input-json
    Reads arguments from a JSON string or file.

--generate-cli-skeleton
    Prints a JSON skeleton to standard output, helpful for creating input for --cli-input-json.

specific parameters
    Each Lambda subcommand has its own set of unique parameters for function names, code, configurations, etc. Refer to the AWS CLI documentation for comprehensive details.

DESCRIPTION

The aws lambda command is a sub-command of the AWS Command Line Interface (AWS CLI), a unified tool for managing your AWS services. It provides a comprehensive set of commands for interacting with the AWS Lambda service, which is a serverless compute service that runs your code in response to events without provisioning or managing servers. Users can perform various operations such as creating, updating, invoking, and deleting Lambda functions; managing event source mappings; configuring function permissions; and retrieving function logs and configurations. This command simplifies automation of Lambda-related tasks, integration into CI/CD pipelines, and enables programmatic control over serverless resources directly from the command line or scripts. It requires the AWS CLI to be installed and configured with appropriate AWS credentials.

CAVEATS

The aws lambda command is not a standalone Linux command but a subcommand of the AWS CLI tool.
It requires the AWS CLI to be installed and configured with valid AWS credentials and permissions to interact with the Lambda service.
Internet connectivity is essential for communication with AWS services.
Understanding of AWS Identity and Access Management (IAM) is crucial for managing permissions securely for Lambda functions and resources.

INSTALLATION

The AWS CLI (v2 recommended) can be installed on Linux by downloading the official installer from AWS. For example: curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

COMMON USE CASES

Deploying new Lambda functions and updating existing function code and configuration.
Invoking Lambda functions directly for testing or as part of automated workflows.
Listing, describing, and deleting Lambda functions and event source mappings.
Configuring permissions and environment variables for serverless applications.
Automating serverless application deployments within CI/CD pipelines.

HISTORY

AWS Lambda itself was launched in 2014, pioneering the serverless computing paradigm.
The AWS CLI, which provides the aws lambda functionality, was first released in 2013 by Amazon Web Services.
It was developed to provide a consistent and unified command-line interface for managing all AWS services, abstracting away the underlying API complexities.
Initially, managing AWS resources often involved custom scripts or the AWS Management Console. The CLI brought robust scripting capabilities and automation to system administrators and developers.
The aws lambda commands have evolved significantly with the Lambda service, adding support for new runtimes, layers, provisioned concurrency, and other features as they were introduced.
Its usage has become indispensable for DevOps practices, CI/CD pipelines, and advanced automation of serverless deployments.

SEE ALSO

aws(1): The main AWS Command Line Interface tool., aws s3(1): Manage Amazon S3 cloud storage., aws iam(1): Manage AWS Identity and Access Management., curl(1): Often used in conjunction for interacting with API Gateway endpoints that front Lambda functions.

Copied to clipboard