AWS Lambda CLI Guide for the Confused Developer

AWS Lambda is a compute service that lets you run code without provisioning or managing servers

Contents

Before you dive into the details of AWS Lambda CLI, I hope you have some familiarity with what Lambda is. At a bare minimum make sure you understand these Lambda concepts –

        • Alias: 
        • Concurrency
        • Event
        • Event Source Mappings
        • Function
        • Layers
        • Runtime
        • Tags
        • Trigger

These are not all encompassing, but its a good start. Also, make sure to read up on some of the features and use cases for lambda

AWS Lambda does not have a separate Command Line Interface. To use AWS Lambda CLI, you have to use the AWS CLI (Command Line Interface), which is an open source tool that enables interaction with Lambda using command-line shell (Linux, macOS, PowerShell). The AWS CLI then provides direct access to the public API  using Boto to interact with the Lambda API. 

If you do not have AWS CLI installed, follow the steps listed in this official AWS CLI documentation.

AWS Lambda CLI Commands

There are a total of 49 Lambda API commands.  I have grouped them into 11 categories based on their functions: ADD, CREATE, DELETE, GET,INVOKE, LIST, PUBLISH, PUT, REMOVE, TAG/UNTAG and UPDATE.

Lambda ADD Commands

#
Command
Description
Syntax
1.
add-layer-version-permission
Used to grant layer usage permission to a single account, all AWS accounts, or all accounts in an organization
add–layer–version–permission
    ––layer–name value
    ––version–number value
    ––statement–id value
    ––action value
    ––principal value
    [––organization–id value]
    [––revision–id value]
    [––cli–input–json value]
    [––generate–cli–skeleton value]

2.
add-permission
Grants an AWS service or account permission to use a function
add–permission
    ––function–name value
    ––statement–id value
    ––action value
    ––principal value
    [––source–arn value]
    [––source–account value]
    [––event–source–token value]
    [––qualifier value]
    [––revision–id value]
    [––cli–input–json value]
    [––generate–cli–skeleton value]

Lambda CREATE Commands

#
Command
Description
Syntax
1.
create-alias
Used to create an alias for a Lambda function version
create–alias
   ––function–name value
   ––name value
   ––function–version value
   [––description value]
   [––routing–config value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

2.
create-event-source-mapping
Used to create a mapping between an event source and an AWS Lambda function
create–event–source–mapping
  ––uuid value
  [––cli–input–json value]
  [––generate–cli–skeleton value]

3.
create-function
Used to create a Lambda function
create–function
    ––runtime value
   ––function–name value
   ––role value
   ––handler value
   [––code value]
   [––description value]
   [––timeout value]
   [––memory–size value]
   [––publish | ––no–publish]
   [––vpc–config value]
   [––dead–letter–config value]
   [––environment value]
   [––kms–key–arn value]
   [––tracing–config value]
   [––tags value]
   [––layers value]
   [––zip–file value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

Lambda DELETE Commands

#
Command
Description
Syntax
1.
delete-alias
Used to delete a Lambda function alias
delete–alias
   ––function–name value
   ––name value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

2.
delete-event-source-mapping
Used to delete an event source mapping
delete–event–source–mapping
   ––uuid value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

3.
delete-function
Used to delete a Lambda function
delete–function
   ––function–name value
   [––qualifier value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

4.
delete-function-concurrency
Used to remove a concurrent execution limit from a function
delete–function–concurrency
   ––function–name value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

5.
delete-function-event-invoke-config
Used to delete the configuration for asynchronous invocation for a function, version, or alias
delete–function–event–invoke–config
   ––function–name value
   [––qualifier value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

6.
delete-layer-version
Used to delete a version of a Lambda layer
delete–layer–version
   ––layer–name value
   ––version–number value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

7.
delete-provisioned-concurrency-config
Used to delete the provisioned concurrency configuration for a function
delete–provisioned–concurrency–config
   ––function–name value
   ––qualifier value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

Lambda GET Commands

#
Command
Description
Syntax
1.
get-account-settings
Used to retrieve details about account limits and usage in an AWS Region
get–account–settings
   [––cli–input–json value]
   [––generate–cli–skeleton value]

2.
get-alias
Used to return details about a Lambda function alias
get–alias
   ––function–name value
   ––name value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

3.
get-event-source-mapping
Used to get details about an event source mapping
get–event–source–mapping
   ––uuid value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

4.
get-function
Used to get information about function(s), with a link to download the deployment package
get–function
   ––function–name value
   [––qualifier value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

5.
get-function-concurrency
Used to get details about the concurrency configuration of a function
get–function–concurrency
   ––function–name value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

6.
get-function-configuration
Used to get the version specific settings of a Lambda function or version
get–function–configuration
   ––function–name value
   [––qualifier value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

7.
get-function-event-invoke-config
Used to get the configuration for asynchronous invocation for a function, version, or alias
get–function–event–invoke–config
   ––function–name value
   [––qualifier value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

8.
get-layer-version
Used to get version information of a AWS Lambda layer, and a link to download the layer archive
get–layer–version
   ––layer–name value
   ––version–number value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

9.
get-layer-version-by-arn
Used to get version information of a AWS Lambda layer, and a link to download the layer archive by ARN
get–layer–version–by–arn
   ––arn value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

10.
get-layer-version-policy
Used to get the permission policy for a version of an AWS Lambda layer
get–layer–version–policy
   ––layer–name value
   ––version–number value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

11.
get-policy
Used to get the resource-based IAM policy for a function, version, or alias
get–policy
   ––function–name value
   [––qualifier value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

12.
get-provisioned-concurrency-config
Used to get the provisioned concurrency configuration for a function’s alias or version
get–provisioned–concurrency–config
   ––function–name value
   ––qualifier value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

Lambda INVOKE Command

#
Command
Description
Syntax
1.
invoke
Used to invoke a Lambda function synchronously or asynchronously
invoke
   ––function–name value
   [––invocation–type value]
   [––log–type value]
   [––client–context value]
   [––payload value]
   [––qualifier value]
   outfile value

Lambda LIST Commands

#
Command
Description
Syntax
1.
list-aliases
Used to returns a list of aliases for a Lambda function
list–aliases
   ––function–name value
   [––function–version value]
   [––max–items value]
   [––cli–input–json value]
   [––starting–token value]
   [––page–size value]
   [––generate–cli–skeleton value]

2.
list-event-source-mappings
Used to list all event source mappings
list–event–source–mappings
   [––event–source–arn value]
   [––function–name value]
   [––max–items value]
   [––cli–input–json value]
   [––starting–token value]
   [––page–size value]
   [––generate–cli–skeleton value]

3.
list-function-event-invoke-configs
Used to retrieves a list of configurations for asynchronous invocation of a Lambda function
list–function–event–invoke–configs
   ––function–name value
   [––max–items value]
   [––cli–input–json value]
   [––starting–token value]
   [––page–size value]
   [––generate–cli–skeleton value]

4.
list-functions
Used to retrieve a list of Lambda functions, with version specific configurations
list–functions
   [––master–region value]
   [––function–version value]
   [––max–items value]
   [––cli–input–json value]
   [––starting–token value]
   [––page–size value]
   [––generate–cli–skeleton value]

5.
list-layer-versions
Used to list the versions of a Lambda layer
list–layer–versions
   [––compatible–runtime value]
   ––layer–name value
   [––max–items value]
   [––cli–input–json value]
   [––starting–token value]
   [––page–size value]
   [––generate–cli–skeleton value]

6.
list-layers
Used to list Lambda layers and shows information about the latest version of each
list–layers
   [––compatible–runtime value]
   [––max–items value]
   [––cli–input–json value]
   [––starting–token value]
   [––page–size value]
   [––generate–cli–skeleton value]
7.
list-provisioned-concurrency-configs
Used to list provisioned concurrency configurations of a function
list–provisioned–concurrency–configs
   ––function–name value
   [––max–items value]
   [––cli–input–json value]
   [––starting–token value]
   [––page–size value]
   [––generate–cli–skeleton value]

8.
list-tags
Used to display the tags attached to a lambda function
list–tags
   ––resource value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

9.
list-versions-by-function
Used to display the version of a Lambda function
list–versions–by–function
   ––function–name value
   [––max–items value]
   [––cli–input–json value]
   [––starting–token value]
   [––page–size value]
   [––generate–cli–skeleton value]

Lambda PUBLISH Commands

#
Command
Description
Syntax
1.
publish-layer-version
Used to create a Lambda layer from a ZIP archive
publish–layer–version
   ––layer–name value
   [––description value]
   [––content value]
   [––compatible–runtimes value]
   [––license–info value]
   [––zip–file value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

2.
publish-version
Used to create a version from the current code and configuration of a function
publish–version
   ––function–name value
   [––code–sha256 value]
   [––description value]
   [––revision–id value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

Lambda PUT Commands

#
Command
Description
Syntax
1.
put-function-concurrency
Used to set the maximum number of simultaneous executions for a function, and reserves capacity for that concurrency level
put–function–concurrency
   ––function–name value
   ––reserved–concurrent–executions value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

2.
put-function-event-invoke-config
Used to configure options for asynchronous invocation on a function, version, or alias
put–function–event–invoke–config
   ––function–name value
   [––qualifier value]
   [––maximum–retry–attempts value]
   [––maximum–event–age–in–seconds value]
   [––destination–config value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

3.
put-provisioned-concurrency-config
Used to add a provisioned concurrency configuration to a function’s alias or version.
put–provisioned–concurrency–config
   ––function–name value
   ––qualifier value
   ––provisioned–concurrent–executions value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

Lambda REMOVE Commands

#
Command
Description
Syntax
1.
remove-layer-version-permission
Used to remove a statement from the permissions policy for a version of an AWS Lambda layer
remove–layer–version–permission
   ––layer–name value
   ––version–number value
   ––statement–id value
   [––revision–id value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

2.
remove-permission
Used to revoke function-use permission from an AWS service/account.
remove–permission
   ––function–name value
   ––statement–id value
   [––qualifier value]
   [––revision–id value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

Lambda TAG/UNTAG Commands

#
Command
Description
Syntax
1.
tag-resource
Used to add tags to a Lambda function
tag–resource
   ––resource value
   ––tags value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

2.
untag-resource
Used to remove tags from a Lambda function
untag–resource
   ––resource value
   ––tag–keys value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

Lambda UPDATE Commands

#
Command
Description
Syntax
1.
update-alias
Used to update the configuration of a Lambda function alias
update–alias
   ––function–name value
   ––name value
   [––function–version value]
   [––description value]
   [––routing–config value]
   [––revision–id value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

2.
untag-resource
Used to remove tags from a function
untag–resource
   ––resource value
   ––tag–keys value
   [––cli–input–json value]
   [––generate–cli–skeleton value]

3.
update-event-source-mapping
Used to update an event source mapping
update–event–source–mapping
   ––uuid value
   [––function–name value]
   [––enabled | ––no–enabled]
   [––batch–size value]
   [––maximum–batching–window–in–seconds value]
   [––destination–config value]
   [––maximum–record–age–in–seconds value]
   [––bisect–batch–on–function–error | ––no–bisect–batch–on–function–error]
   [––maximum–retry–attempts value]
   [––parallelization–factor value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

4.
update-function-code
Used to update a Lambda function code
update–function–code
   ––function–name value
   [––zip–file value]
   [––s3–bucket value]
   [––s3–key value]
   [––s3–object–version value]
   [––publish | ––no–publish]
   [––dry–run | ––no–dry–run]
   [––revision–id value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

5.
update-function-configuration
Used to modify version specific settings of a Lambda function
update–function–configuration
   ––function–name value
   [––role value]
   [––handler value]
   [––description value]
   [––timeout value]
   [––memory–size value]
   [––vpc–config value]
   [––environment value]
   [––runtime value]
   [––dead–letter–config value]
   [––kms–key–arn value]
   [––tracing–config value]
   [––revision–id value]
   [––layers value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

6.
update-function-event-invoke-config
Used to update the configuration for asynchronous invocation for a function, version, or alias
update–function–event–invoke–config
   ––function–name value
   [––qualifier value]
   [––maximum–retry–attempts value]
   [––maximum–event–age–in–seconds value]
   [––destination–config value]
   [––cli–input–json value]
   [––generate–cli–skeleton value]

AWS Lambda integrates with AWS CloudFormation

Would you like to read our blog post on CloudFormation Parameters ?

Email us at : info@obstkel.com

Copyright 2020 © OBSTKEL LLC. All rights Reserved.
Scroll to Top