This documentation is for Version 1 of the Amazon CLI only. For documentation related to Version 2 of the Amazon CLI, see the Version 2 User Guide.
Lambda examples using Amazon CLI
The following code examples show you how to perform actions and implement common scenarios by using the Amazon Command Line Interface with Lambda.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use add-layer-version-permission.
- Amazon CLI
-
To add permissions to a layer version
The following
add-layer-version-permissionexample grants permission for the specified account to use version 1 of the layermy-layer.aws lambda add-layer-version-permission \ --layer-namemy-layer\ --statement-idxaccount\ --actionlambda:GetLayerVersion\ --principal123456789012\ --version-number1Output:
{ "RevisionId": "35d87451-f796-4a3f-a618-95a3671b0a0c", "Statement": { "Sid":"xaccount", "Effect":"Allow", "Principal":{ "AWS":"arn:aws:iam::210987654321:root" }, "Action":"lambda:GetLayerVersion", "Resource":"arn:aws:lambda:us-east-2:123456789012:layer:my-layer:1" } }For more information, see Amazon Lambda Layers
in the Amazon Lambda Developer Guide. -
For API details, see AddLayerVersionPermission
in Amazon CLI Command Reference.
-
The following code example shows how to use add-permission.
- Amazon CLI
-
To add permissions to an existing Lambda function
The following
add-permissionexample grants the Amazon SNS service permission to invoke a function namedmy-function.aws lambda add-permission \ --function-namemy-function\ --actionlambda:InvokeFunction\ --statement-idsns\ --principalsns.amazonaws.comOutput:
{ "Statement": { "Sid":"sns", "Effect":"Allow", "Principal":{ "Service":"sns.amazonaws.com" }, "Action":"lambda:InvokeFunction", "Resource":"arn:aws:lambda:us-east-2:123456789012:function:my-function" } }For more information, see Using Resource-based Policies for Amazon Lambda
in the Amazon Lambda Developer Guide. -
For API details, see AddPermission
in Amazon CLI Command Reference.
-
The following code example shows how to use create-alias.
- Amazon CLI
-
To create an alias for a Lambda function
The following
create-aliasexample creates an alias namedLIVEthat points to version 1 of themy-functionLambda function.aws lambda create-alias \ --function-namemy-function\ --description"alias for live version of function"\ --function-version1\ --nameLIVEOutput:
{ "FunctionVersion": "1", "Name": "LIVE", "AliasArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function:LIVE", "RevisionId": "873282ed-4cd3-4dc8-a069-d0c647e470c6", "Description": "alias for live version of function" }For more information, see Configuring Amazon Lambda Function Aliases
in the Amazon Lambda Developer Guide. -
For API details, see CreateAlias
in Amazon CLI Command Reference.
-
The following code example shows how to use create-event-source-mapping.
- Amazon CLI
-
To create a mapping between an event source and an Amazon Lambda function
The following
create-event-source-mappingexample creates a mapping between an SQS queue and themy-functionLambda function.aws lambda create-event-source-mapping \ --function-namemy-function\ --batch-size5\ --event-source-arnarn:aws:sqs:us-west-2:123456789012:mySQSqueueOutput:
{ "UUID": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "StateTransitionReason": "USER_INITIATED", "LastModified": 1569284520.333, "BatchSize": 5, "State": "Creating", "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function", "EventSourceArn": "arn:aws:sqs:us-west-2:123456789012:mySQSqueue" }For more information, see Amazon Lambda Event Source Mapping
in the Amazon Lambda Developer Guide. -
For API details, see CreateEventSourceMapping
in Amazon CLI Command Reference.
-
The following code example shows how to use create-function.
- Amazon CLI
-
To create a Lambda function
The following
create-functionexample creates a Lambda function namedmy-function.aws lambda create-function \ --function-namemy-function\ --runtimenodejs22.x\ --zip-filefileb://my-function.zip\ --handlermy-function.handler\ --rolearn:aws:iam::123456789012:role/service-role/MyTestFunction-role-tges6bf4Contents of
my-function.zip:This file is a deployment package that contains your function code and any dependencies.Output:
{ "TracingConfig": { "Mode": "PassThrough" }, "CodeSha256": "PFn4S+er27qk+UuZSTKEQfNKG/XNn7QJs90mJgq6oH8=", "FunctionName": "my-function", "CodeSize": 308, "RevisionId": "873282ed-4cd3-4dc8-a069-d0c647e470c6", "MemorySize": 128, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function", "Version": "$LATEST", "Role": "arn:aws:iam::123456789012:role/service-role/MyTestFunction-role-zgur6bf4", "Timeout": 3, "LastModified": "2025-10-14T22:26:11.234+0000", "Handler": "my-function.handler", "Runtime": "nodejs22.x", "Description": "" }For more information, see Configure Lambda function memory
in the Amazon Lambda Developer Guide. -
For API details, see CreateFunction
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-alias.
- Amazon CLI
-
To delete an alias of a Lambda function
The following
delete-aliasexample deletes the alias namedLIVEfrom themy-functionLambda function.aws lambda delete-alias \ --function-namemy-function\ --nameLIVEThis command produces no output.
For more information, see Configuring Amazon Lambda Function Aliases
in the Amazon Lambda Developer Guide. -
For API details, see DeleteAlias
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-event-source-mapping.
- Amazon CLI
-
To delete the mapping between an event source and an Amazon Lambda function
The following
delete-event-source-mappingexample deletes the mapping between an SQS queue and themy-functionLambda function.aws lambda delete-event-source-mapping \ --uuida1b2c3d4-5678-90ab-cdef-11111EXAMPLEOutput:
{ "UUID": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "StateTransitionReason": "USER_INITIATED", "LastModified": 1569285870.271, "BatchSize": 5, "State": "Deleting", "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function", "EventSourceArn": "arn:aws:sqs:us-west-2:123456789012:mySQSqueue" }For more information, see Amazon Lambda Event Source Mapping
in the Amazon Lambda Developer Guide. -
For API details, see DeleteEventSourceMapping
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-function-concurrency.
- Amazon CLI
-
To remove the reserved concurrent execution limit from a function
The following
delete-function-concurrencyexample deletes the reserved concurrent execution limit from themy-functionfunction.aws lambda delete-function-concurrency \ --function-namemy-functionThis command produces no output.
For more information, see Reserving Concurrency for a Lambda Function
in the Amazon Lambda Developer Guide. -
For API details, see DeleteFunctionConcurrency
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-function-event-invoke-config.
- Amazon CLI
-
To delete an asynchronous invocation configuration
The following
delete-function-event-invoke-configexample deletes the asynchronous invocation configuration for theGREENalias of the specified function.aws lambda delete-function-event-invoke-config --function-namemy-function:GREEN-
For API details, see DeleteFunctionEventInvokeConfig
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-function.
- Amazon CLI
-
Example 1: To delete a Lambda function by function name
The following
delete-functionexample deletes the Lambda function namedmy-functionby specifying the function's name.aws lambda delete-function \ --function-namemy-functionThis command produces no output.
Example 2: To delete a Lambda function by function ARN
The following
delete-functionexample deletes the Lambda function namedmy-functionby specifying the function's ARN.aws lambda delete-function \ --function-namearn:aws:lambda:us-west-2:123456789012:function:my-functionThis command produces no output.
Example 3: To delete a Lambda function by partial function ARN
The following
delete-functionexample deletes the Lambda function namedmy-functionby specifying the function's partial ARN.aws lambda delete-function \ --function-name123456789012:function:my-functionThis command produces no output.
For more information, see Amazon Lambda Function Configuration
in the Amazon Lambda Developer Guide. -
For API details, see DeleteFunction
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-layer-version.
- Amazon CLI
-
To delete a version of a Lambda layer
The following
delete-layer-versionexample deletes version 2 of the layer namedmy-layer.aws lambda delete-layer-version \ --layer-namemy-layer\ --version-number2This command produces no output.
For more information, see Amazon Lambda Layers
in the Amazon Lambda Developer Guide. -
For API details, see DeleteLayerVersion
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-provisioned-concurrency-config.
- Amazon CLI
-
To delete a provisioned concurrency configuration
The following
delete-provisioned-concurrency-configexample deletes the provisioned concurrency configuration for theGREENalias of the specified function.aws lambda delete-provisioned-concurrency-config \ --function-namemy-function\ --qualifierGREEN-
For API details, see DeleteProvisionedConcurrencyConfig
in Amazon CLI Command Reference.
-
The following code example shows how to use get-account-settings.
- Amazon CLI
-
To retrieve details about your account in an Amazon Region
The following
get-account-settingsexample displays the Lambda limits and usage information for your account.aws lambda get-account-settingsOutput:
{ "AccountLimit": { "CodeSizeUnzipped": 262144000, "UnreservedConcurrentExecutions": 1000, "ConcurrentExecutions": 1000, "CodeSizeZipped": 52428800, "TotalCodeSize": 80530636800 }, "AccountUsage": { "FunctionCount": 4, "TotalCodeSize": 9426 } }For more information, see Amazon Lambda Limits
in the Amazon Lambda Developer Guide. -
For API details, see GetAccountSettings
in Amazon CLI Command Reference.
-
The following code example shows how to use get-alias.
- Amazon CLI
-
To retrieve details about a function alias
The following
get-aliasexample displays details for the alias namedLIVEon themy-functionLambda function.aws lambda get-alias \ --function-namemy-function\ --nameLIVEOutput:
{ "FunctionVersion": "3", "Name": "LIVE", "AliasArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function:LIVE", "RevisionId": "594f41fb-b85f-4c20-95c7-6ca5f2a92c93", "Description": "alias for live version of function" }For more information, see Configuring Amazon Lambda Function Aliases
in the Amazon Lambda Developer Guide. -
For API details, see GetAlias
in Amazon CLI Command Reference.
-
The following code example shows how to use get-event-source-mapping.
- Amazon CLI
-
To retrieve details about an event source mapping
The following
get-event-source-mappingexample displays the details for the mapping between an SQS queue and themy-functionLambda function.aws lambda get-event-source-mapping \ --uuid"a1b2c3d4-5678-90ab-cdef-11111EXAMPLE"Output:
{ "UUID": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "StateTransitionReason": "USER_INITIATED", "LastModified": 1569284520.333, "BatchSize": 5, "State": "Enabled", "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function", "EventSourceArn": "arn:aws:sqs:us-west-2:123456789012:mySQSqueue" }For more information, see Amazon Lambda Event Source Mapping
in the Amazon Lambda Developer Guide. -
For API details, see GetEventSourceMapping
in Amazon CLI Command Reference.
-
The following code example shows how to use get-function-concurrency.
- Amazon CLI
-
To view the reserved concurrency setting for a function
The following
get-function-concurrencyexample retrieves the reserved concurrency setting for the specified function.aws lambda get-function-concurrency \ --function-namemy-functionOutput:
{ "ReservedConcurrentExecutions": 250 }-
For API details, see GetFunctionConcurrency
in Amazon CLI Command Reference.
-
The following code example shows how to use get-function-configuration.
- Amazon CLI
-
To retrieve the version-specific settings of a Lambda function
The following
get-function-configurationexample displays the settings for version 2 of themy-functionfunction.aws lambda get-function-configuration \ --function-namemy-function:2Output:
{ "FunctionName": "my-function", "LastModified": "2019-09-26T20:28:40.438+0000", "RevisionId": "e52502d4-9320-4688-9cd6-152a6ab7490d", "MemorySize": 256, "Version": "2", "Role": "arn:aws:iam::123456789012:role/service-role/my-function-role-uy3l9qyq", "Timeout": 3, "Runtime": "nodejs10.x", "TracingConfig": { "Mode": "PassThrough" }, "CodeSha256": "5tT2qgzYUHaqwR716pZ2dpkn/0J1FrzJmlKidWoaCgk=", "Description": "", "VpcConfig": { "SubnetIds": [], "VpcId": "", "SecurityGroupIds": [] }, "CodeSize": 304, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function:2", "Handler": "index.handler" }For more information, see Amazon Lambda Function Configuration
in the Amazon Lambda Developer Guide. -
For API details, see GetFunctionConfiguration
in Amazon CLI Command Reference.
-
The following code example shows how to use get-function-event-invoke-config.
- Amazon CLI
-
To view an asynchronous invocation configuration
The following
get-function-event-invoke-configexample retrieves the asynchronous invocation configuration for theBLUEalias of the specified function.aws lambda get-function-event-invoke-config \ --function-namemy-function:BLUEOutput:
{ "LastModified": 1577824396.653, "FunctionArn": "arn:aws:lambda:us-east-2:123456789012:function:my-function:BLUE", "MaximumRetryAttempts": 0, "MaximumEventAgeInSeconds": 3600, "DestinationConfig": { "OnSuccess": {}, "OnFailure": { "Destination": "arn:aws:sqs:us-east-2:123456789012:failed-invocations" } } }-
For API details, see GetFunctionEventInvokeConfig
in Amazon CLI Command Reference.
-
The following code example shows how to use get-function.
- Amazon CLI
-
To retrieve information about a function
The following
get-functionexample displays information about themy-functionfunction.aws lambda get-function \ --function-namemy-functionOutput:
{ "Concurrency": { "ReservedConcurrentExecutions": 100 }, "Code": { "RepositoryType": "S3", "Location": "https://awslambda-us-west-2-tasks.s3.us-west-2.amazonaws.com/snapshots/123456789012/my-function..." }, "Configuration": { "TracingConfig": { "Mode": "PassThrough" }, "Version": "$LATEST", "CodeSha256": "5tT2qgzYUHoqwR616pZ2dpkn/0J1FrzJmlKidWaaCgk=", "FunctionName": "my-function", "VpcConfig": { "SubnetIds": [], "VpcId": "", "SecurityGroupIds": [] }, "MemorySize": 128, "RevisionId": "28f0fb31-5c5c-43d3-8955-03e76c5c1075", "CodeSize": 304, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function", "Handler": "index.handler", "Role": "arn:aws:iam::123456789012:role/service-role/helloWorldPython-role-uy3l9qyq", "Timeout": 3, "LastModified": "2025-09-24T18:20:35.054+0000", "Runtime": "nodejs22.x", "Description": "" } }For more information, see Configure Lambda function memory
in the Amazon Lambda Developer Guide. -
For API details, see GetFunction
in Amazon CLI Command Reference.
-
The following code example shows how to use get-layer-version-by-arn.
- Amazon CLI
-
To retrieve information about a Lambda layer version
The following
get-layer-version-by-arnexample displays information about the layer version with the specified Amazon Resource Name (ARN).aws lambda get-layer-version-by-arn \ --arn"arn:aws:lambda:us-west-2:123456789012:layer:AWSLambda-Python311-SciPy1x:2"Output:
{ "LayerVersionArn": "arn:aws:lambda:us-west-2:123456789012:layer:AWSLambda-Python311-SciPy1x:2", "Description": "AWS Lambda SciPy layer for Python 3.11 (scipy-1.1.0, numpy-1.15.4) https://github.com/scipy/scipy/releases/tag/v1.1.0 https://github.com/numpy/numpy/releases/tag/v1.15.4", "CreatedDate": "2023-10-12T10:09:38.398+0000", "LayerArn": "arn:aws:lambda:us-west-2:123456789012:layer:AWSLambda-Python311-SciPy1x", "Content": { "CodeSize": 41784542, "CodeSha256": "GGmv8ocUw4cly0T8HL0Vx/f5V4RmSCGNjDIslY4VskM=", "Location": "https://awslambda-us-west-2-layers.s3.us-west-2.amazonaws.com/snapshots/123456789012/..." }, "Version": 2, "CompatibleRuntimes": [ "python3.11" ], "LicenseInfo": "SciPy: https://github.com/scipy/scipy/blob/main/LICENSE.txt, NumPy: https://github.com/numpy/numpy/blob/main/LICENSE.txt" }For more information, see Amazon Lambda Layers
in the Amazon Lambda Developer Guide. -
For API details, see GetLayerVersionByArn
in Amazon CLI Command Reference.
-
The following code example shows how to use get-layer-version-policy.
- Amazon CLI
-
To retrieve the permissions policy for a Lambda layer version
The following
get-layer-version-policyexample displays policy information about version 1 for the layer namedmy-layer.aws lambda get-layer-version-policy \ --layer-namemy-layer\ --version-number1Output:
{ "Policy": { "Version":"2012-10-17", "Id":"default", "Statement": [ { "Sid":"xaccount", "Effect":"Allow", "Principal": {"AWS":"arn:aws:iam::123456789012:root"}, "Action":"lambda:GetLayerVersion", "Resource":"arn:aws:lambda:us-west-2:123456789012:layer:my-layer:1" } ] }, "RevisionId": "c68f21d2-cbf0-4026-90f6-1375ee465cd0" }For more information, see Amazon Lambda Layers
in the Amazon Lambda Developer Guide. -
For API details, see GetLayerVersionPolicy
in Amazon CLI Command Reference.
-
The following code example shows how to use get-layer-version.
- Amazon CLI
-
To retrieve information about a Lambda layer version
The following
get-layer-versionexample displays information for version 1 of the layer namedmy-layer.aws lambda get-layer-version \ --layer-namemy-layer\ --version-number1Output:
{ "Content": { "Location": "https://awslambda-us-east-2-layers.s3.us-east-2.amazonaws.com/snapshots/123456789012/my-layer-4aaa2fbb-ff77-4b0a-ad92-5b78a716a96a?versionId=27iWyA73cCAYqyH...", "CodeSha256": "tv9jJO+rPbXUUXuRKi7CwHzKtLDkDRJLB3cC3Z/ouXo=", "CodeSize": 169 }, "LayerArn": "arn:aws:lambda:us-east-2:123456789012:layer:my-layer", "LayerVersionArn": "arn:aws:lambda:us-east-2:123456789012:layer:my-layer:1", "Description": "My Python layer", "CreatedDate": "2018-11-14T23:03:52.894+0000", "Version": 1, "LicenseInfo": "MIT", "CompatibleRuntimes": [ "python3.10", "python3.11" ] }For more information, see Amazon Lambda Layers
in the Amazon Lambda Developer Guide. -
For API details, see GetLayerVersion
in Amazon CLI Command Reference.
-
The following code example shows how to use get-policy.
- Amazon CLI
-
To retrieve the resource-based IAM policy for a function, version, or alias
The following
get-policyexample displays policy information about themy-functionLambda function.aws lambda get-policy \ --function-namemy-functionOutput:
{ "Policy": { "Version":"2012-10-17", "Id":"default", "Statement": [ { "Sid":"iot-events", "Effect":"Allow", "Principal": {"Service":"iotevents.amazonaws.com"}, "Action":"lambda:InvokeFunction", "Resource":"arn:aws:lambda:us-west-2:123456789012:function:my-function" } ] }, "RevisionId": "93017fc9-59cb-41dc-901b-4845ce4bf668" }For more information, see Using Resource-based Policies for Amazon Lambda
in the Amazon Lambda Developer Guide. -
For API details, see GetPolicy
in Amazon CLI Command Reference.
-
The following code example shows how to use get-provisioned-concurrency-config.
- Amazon CLI
-
To view a provisioned concurrency configuration
The following
get-provisioned-concurrency-configexample displays details for the provisioned concurrency configuration for theBLUEalias of the specified function.aws lambda get-provisioned-concurrency-config \ --function-namemy-function\ --qualifierBLUEOutput:
{ "RequestedProvisionedConcurrentExecutions": 100, "AvailableProvisionedConcurrentExecutions": 100, "AllocatedProvisionedConcurrentExecutions": 100, "Status": "READY", "LastModified": "2019-12-31T20:28:49+0000" }-
For API details, see GetProvisionedConcurrencyConfig
in Amazon CLI Command Reference.
-
The following code example shows how to use invoke.
- Amazon CLI
-
Example 1: To invoke a Lambda function synchronously
The following
invokeexample invokes themy-functionfunction synchronously. Thecli-binary-formatoption is required if you're using Amazon CLI version 2. For more information, see Amazon CLI supported global command line optionsin the Amazon Command Line Interface User Guide. aws lambda invoke \ --function-namemy-function\ --cli-binary-formatraw-in-base64-out\ --payload '{ "name": "Bob" }' \response.jsonOutput:
{ "ExecutedVersion": "$LATEST", "StatusCode": 200 }For more information, see Invoke a Lambda function synchronously
in the Amazon Lambda Developer Guide. Example 2: To invoke a Lambda function asynchronously
The following
invokeexample invokes themy-functionfunction asynchronously. Thecli-binary-formatoption is required if you're using Amazon CLI version 2. For more information, see Amazon CLI supported global command line optionsin the Amazon Command Line Interface User Guide. aws lambda invoke \ --function-namemy-function\ --invocation-typeEvent\ --cli-binary-formatraw-in-base64-out\ --payload '{ "name": "Bob" }' \response.jsonOutput:
{ "StatusCode": 202 }For more information, see Invoking a Lambda function asynchronously
in the Amazon Lambda Developer Guide. -
For API details, see Invoke
in Amazon CLI Command Reference.
-
The following code example shows how to use list-aliases.
- Amazon CLI
-
To retrieve the list of aliases for a Lambda function
The following
list-aliasesexample displays a list of the aliases for themy-functionLambda function.aws lambda list-aliases \ --function-namemy-functionOutput:
{ "Aliases": [ { "AliasArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function:BETA", "RevisionId": "a410117f-ab16-494e-8035-7e204bb7933b", "FunctionVersion": "2", "Name": "BETA", "Description": "alias for beta version of function" }, { "AliasArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function:LIVE", "RevisionId": "21d40116-f8b1-40ba-9360-3ea284da1bb5", "FunctionVersion": "1", "Name": "LIVE", "Description": "alias for live version of function" } ] }For more information, see Configuring Amazon Lambda Function Aliases
in the Amazon Lambda Developer Guide. -
For API details, see ListAliases
in Amazon CLI Command Reference.
-
The following code example shows how to use list-event-source-mappings.
- Amazon CLI
-
To list the event source mappings for a function
The following
list-event-source-mappingsexample displays a list of the event source mappings for themy-functionLambda function.aws lambda list-event-source-mappings \ --function-namemy-functionOutput:
{ "EventSourceMappings": [ { "UUID": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "StateTransitionReason": "USER_INITIATED", "LastModified": 1569284520.333, "BatchSize": 5, "State": "Enabled", "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function", "EventSourceArn": "arn:aws:sqs:us-west-2:123456789012:mySQSqueue" } ] }For more information, see Amazon Lambda Event Source Mapping
in the Amazon Lambda Developer Guide. -
For API details, see ListEventSourceMappings
in Amazon CLI Command Reference.
-
The following code example shows how to use list-function-event-invoke-configs.
- Amazon CLI
-
To view a list of asynchronous invocation configurations
The following
list-function-event-invoke-configsexample lists the asynchronous invocation configurations for the specified function.aws lambda list-function-event-invoke-configs \ --function-namemy-functionOutput:
{ "FunctionEventInvokeConfigs": [ { "LastModified": 1577824406.719, "FunctionArn": "arn:aws:lambda:us-east-2:123456789012:function:my-function:GREEN", "MaximumRetryAttempts": 2, "MaximumEventAgeInSeconds": 1800 }, { "LastModified": 1577824396.653, "FunctionArn": "arn:aws:lambda:us-east-2:123456789012:function:my-function:BLUE", "MaximumRetryAttempts": 0, "MaximumEventAgeInSeconds": 3600 } ] }-
For API details, see ListFunctionEventInvokeConfigs
in Amazon CLI Command Reference.
-
The following code example shows how to use list-functions.
- Amazon CLI
-
To retrieve a list of Lambda functions
The following
list-functionsexample displays a list of all of the functions for the current user.aws lambda list-functionsOutput:
{ "Functions": [ { "TracingConfig": { "Mode": "PassThrough" }, "Version": "$LATEST", "CodeSha256": "dBG9m8SGdmlEjw/JYXlhhvCrAv5TxvXsbL/RMr0fT/I=", "FunctionName": "helloworld", "MemorySize": 128, "RevisionId": "1718e831-badf-4253-9518-d0644210af7b", "CodeSize": 294, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:helloworld", "Handler": "helloworld.handler", "Role": "arn:aws:iam::123456789012:role/service-role/MyTestFunction-role-zgur6bf4", "Timeout": 3, "LastModified": "2025-09-23T18:32:33.857+0000", "Runtime": "nodejs22.x", "Description": "" }, { "TracingConfig": { "Mode": "PassThrough" }, "Version": "$LATEST", "CodeSha256": "sU0cJ2/hOZevwV/lTxCuQqK3gDZP3i8gUoqUUVRmY6E=", "FunctionName": "my-function", "VpcConfig": { "SubnetIds": [], "VpcId": "", "SecurityGroupIds": [] }, "MemorySize": 256, "RevisionId": "93017fc9-59cb-41dc-901b-4845ce4bf668", "CodeSize": 266, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function", "Handler": "index.handler", "Role": "arn:aws:iam::123456789012:role/service-role/helloWorldPython-role-uy3l9qyq", "Timeout": 3, "LastModified": "2025-10-01T16:47:28.490+0000", "Runtime": "nodejs22.x", "Description": "" }, { "Layers": [ { "CodeSize": 41784542, "Arn": "arn:aws:lambda:us-west-2:420165488524:layer:AWSLambda-Python37-SciPy1x:2" }, { "CodeSize": 4121, "Arn": "arn:aws:lambda:us-west-2:123456789012:layer:pythonLayer:1" } ], "TracingConfig": { "Mode": "PassThrough" }, "Version": "$LATEST", "CodeSha256": "ZQukCqxtkqFgyF2cU41Avj99TKQ/hNihPtDtRcc08mI=", "FunctionName": "my-python-function", "VpcConfig": { "SubnetIds": [], "VpcId": "", "SecurityGroupIds": [] }, "MemorySize": 128, "RevisionId": "80b4eabc-acf7-4ea8-919a-e874c213707d", "CodeSize": 299, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-python-function", "Handler": "lambda_function.lambda_handler", "Role": "arn:aws:iam::123456789012:role/service-role/my-python-function-role-z5g7dr6n", "Timeout": 3, "LastModified": "2025-10-01T19:40:41.643+0000", "Runtime": "python3.11", "Description": "" } ] }For more information, see Configure Lambda function memory
in the Amazon Lambda Developer Guide. -
For API details, see ListFunctions
in Amazon CLI Command Reference.
-
The following code example shows how to use list-layer-versions.
- Amazon CLI
-
To list the versions of an Amazon Lambda layer
The following
list-layers-versionsexample displays information about the versions for the layer namedmy-layer.aws lambda list-layer-versions \ --layer-namemy-layerOutput:
{ "Layers": [ { "LayerVersionArn": "arn:aws:lambda:us-east-2:123456789012:layer:my-layer:2", "Version": 2, "Description": "My layer", "CreatedDate": "2023-11-15T00:37:46.592+0000", "CompatibleRuntimes": [ "python3.10", "python3.11" ] } ] }For more information, see Amazon Lambda Layers
in the Amazon Lambda Developer Guide. -
For API details, see ListLayerVersions
in Amazon CLI Command Reference.
-
The following code example shows how to use list-layers.
- Amazon CLI
-
To list the layers that are compatible with your function's runtime
The following
list-layersexample displays information about layers that are compatible with the Python 3.11 runtime.aws lambda list-layers \ --compatible-runtimepython3.11Output:
{ "Layers": [ { "LayerName": "my-layer", "LayerArn": "arn:aws:lambda:us-east-2:123456789012:layer:my-layer", "LatestMatchingVersion": { "LayerVersionArn": "arn:aws:lambda:us-east-2:123456789012:layer:my-layer:2", "Version": 2, "Description": "My layer", "CreatedDate": "2023-11-15T00:37:46.592+0000", "CompatibleRuntimes": [ "python3.10", "python3.11" ] } } ] }For more information, see Amazon Lambda Layers
in the Amazon Lambda Developer Guide. -
For API details, see ListLayers
in Amazon CLI Command Reference.
-
The following code example shows how to use list-provisioned-concurrency-configs.
- Amazon CLI
-
To get a list of provisioned concurrency configurations
The following
list-provisioned-concurrency-configsexample lists the provisioned concurrency configurations for the specified function.aws lambda list-provisioned-concurrency-configs \ --function-namemy-functionOutput:
{ "ProvisionedConcurrencyConfigs": [ { "FunctionArn": "arn:aws:lambda:us-east-2:123456789012:function:my-function:GREEN", "RequestedProvisionedConcurrentExecutions": 100, "AvailableProvisionedConcurrentExecutions": 100, "AllocatedProvisionedConcurrentExecutions": 100, "Status": "READY", "LastModified": "2019-12-31T20:29:00+0000" }, { "FunctionArn": "arn:aws:lambda:us-east-2:123456789012:function:my-function:BLUE", "RequestedProvisionedConcurrentExecutions": 100, "AvailableProvisionedConcurrentExecutions": 100, "AllocatedProvisionedConcurrentExecutions": 100, "Status": "READY", "LastModified": "2019-12-31T20:28:49+0000" } ] }-
For API details, see ListProvisionedConcurrencyConfigs
in Amazon CLI Command Reference.
-
The following code example shows how to use list-tags.
- Amazon CLI
-
To retrieve the list of tags for a Lambda function
The following
list-tagsexample displays the tags attached to themy-functionLambda function.aws lambda list-tags \ --resourcearn:aws:lambda:us-west-2:123456789012:function:my-functionOutput:
{ "Tags": { "Category": "Web Tools", "Department": "Sales" } }For more information, see Tagging Lambda Functions
in the Amazon Lambda Developer Guide. -
For API details, see ListTags
in Amazon CLI Command Reference.
-
The following code example shows how to use list-versions-by-function.
- Amazon CLI
-
To retrieve a list of versions of a function
The following
list-versions-by-functionexample displays the list of versions for themy-functionLambda function.aws lambda list-versions-by-function \ --function-namemy-functionOutput:
{ "Versions": [ { "TracingConfig": { "Mode": "PassThrough" }, "Version": "$LATEST", "CodeSha256": "sU0cJ2/hOZevwV/lTxCuQqK3gDZP3i8gUoqUUVRmY6E=", "FunctionName": "my-function", "VpcConfig": { "SubnetIds": [], "VpcId": "", "SecurityGroupIds": [] }, "MemorySize": 256, "RevisionId": "93017fc9-59cb-41dc-901b-4845ce4bf668", "CodeSize": 266, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function:$LATEST", "Handler": "index.handler", "Role": "arn:aws:iam::123456789012:role/service-role/helloWorldPython-role-uy3l9qyq", "Timeout": 3, "LastModified": "2019-10-01T16:47:28.490+0000", "Runtime": "nodejs10.x", "Description": "" }, { "TracingConfig": { "Mode": "PassThrough" }, "Version": "1", "CodeSha256": "5tT2qgzYUHoqwR616pZ2dpkn/0J1FrzJmlKidWaaCgk=", "FunctionName": "my-function", "VpcConfig": { "SubnetIds": [], "VpcId": "", "SecurityGroupIds": [] }, "MemorySize": 256, "RevisionId": "949c8914-012e-4795-998c-e467121951b1", "CodeSize": 304, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function:1", "Handler": "index.handler", "Role": "arn:aws:iam::123456789012:role/service-role/helloWorldPython-role-uy3l9qyq", "Timeout": 3, "LastModified": "2019-09-26T20:28:40.438+0000", "Runtime": "nodejs10.x", "Description": "new version" }, { "TracingConfig": { "Mode": "PassThrough" }, "Version": "2", "CodeSha256": "sU0cJ2/hOZevwV/lTxCuQqK3gDZP3i8gUoqUUVRmY6E=", "FunctionName": "my-function", "VpcConfig": { "SubnetIds": [], "VpcId": "", "SecurityGroupIds": [] }, "MemorySize": 256, "RevisionId": "cd669f21-0f3d-4e1c-9566-948837f2e2ea", "CodeSize": 266, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function:2", "Handler": "index.handler", "Role": "arn:aws:iam::123456789012:role/service-role/helloWorldPython-role-uy3l9qyq", "Timeout": 3, "LastModified": "2019-10-01T16:47:28.490+0000", "Runtime": "nodejs10.x", "Description": "newer version" } ] }For more information, see Configuring Amazon Lambda Function Aliases
in the Amazon Lambda Developer Guide. -
For API details, see ListVersionsByFunction
in Amazon CLI Command Reference.
-
The following code example shows how to use publish-layer-version.
- Amazon CLI
-
To create a Lambda layer version
The following
publish-layer-versionexample creates a new Python library layer version. The command retrieves the layer content a file namedlayer.zipin the specified S3 bucket.aws lambda publish-layer-version \ --layer-namemy-layer\ --description"My Python layer"\ --license-info"MIT"\ --contentS3Bucket=lambda-layers-us-west-2-123456789012,S3Key=layer.zip\ --compatible-runtimespython3.10python3.11Output:
{ "Content": { "Location": "https://awslambda-us-west-2-layers.s3.us-west-2.amazonaws.com/snapshots/123456789012/my-layer-4aaa2fbb-ff77-4b0a-ad92-5b78a716a96a?versionId=27iWyA73cCAYqyH...", "CodeSha256": "tv9jJO+rPbXUUXuRKi7CwHzKtLDkDRJLB3cC3Z/ouXo=", "CodeSize": 169 }, "LayerArn": "arn:aws:lambda:us-west-2:123456789012:layer:my-layer", "LayerVersionArn": "arn:aws:lambda:us-west-2:123456789012:layer:my-layer:1", "Description": "My Python layer", "CreatedDate": "2023-11-14T23:03:52.894+0000", "Version": 1, "LicenseInfo": "MIT", "CompatibleRuntimes": [ "python3.10", "python3.11" ] }For more information, see Amazon Lambda Layers
in the Amazon Lambda Developer Guide. -
For API details, see PublishLayerVersion
in Amazon CLI Command Reference.
-
The following code example shows how to use publish-version.
- Amazon CLI
-
To publish a new version of a function
The following
publish-versionexample publishes a new version of themy-functionLambda function.aws lambda publish-version \ --function-namemy-functionOutput:
{ "TracingConfig": { "Mode": "PassThrough" }, "CodeSha256": "dBG9m8SGdmlEjw/JYXlhhvCrAv5TxvXsbL/RMr0fT/I=", "FunctionName": "my-function", "CodeSize": 294, "RevisionId": "f31d3d39-cc63-4520-97d4-43cd44c94c20", "MemorySize": 128, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function:3", "Version": "2", "Role": "arn:aws:iam::123456789012:role/service-role/MyTestFunction-role-zgur6bf4", "Timeout": 3, "LastModified": "2019-09-23T18:32:33.857+0000", "Handler": "my-function.handler", "Runtime": "nodejs10.x", "Description": "" }For more information, see Configuring Amazon Lambda Function Aliases
in the Amazon Lambda Developer Guide. -
For API details, see PublishVersion
in Amazon CLI Command Reference.
-
The following code example shows how to use put-function-concurrency.
- Amazon CLI
-
To configure a reserved concurrency limit for a function
The following
put-function-concurrencyexample configures 100 reserved concurrent executions for themy-functionfunction.aws lambda put-function-concurrency \ --function-namemy-function\ --reserved-concurrent-executions100Output:
{ "ReservedConcurrentExecutions": 100 }For more information, see Reserving Concurrency for a Lambda Function
in the Amazon Lambda Developer Guide. -
For API details, see PutFunctionConcurrency
in Amazon CLI Command Reference.
-
The following code example shows how to use put-function-event-invoke-config.
- Amazon CLI
-
To configure error handling for asynchronous invocation
The following
put-function-event-invoke-configexample sets a maximum event age of one hour and disables retries for the specified function.aws lambda put-function-event-invoke-config \ --function-namemy-function\ --maximum-event-age-in-seconds3600\ --maximum-retry-attempts0Output:
{ "LastModified": 1573686021.479, "FunctionArn": "arn:aws:lambda:us-east-2:123456789012:function:my-function:$LATEST", "MaximumRetryAttempts": 0, "MaximumEventAgeInSeconds": 3600, "DestinationConfig": { "OnSuccess": {}, "OnFailure": {} } }-
For API details, see PutFunctionEventInvokeConfig
in Amazon CLI Command Reference.
-
The following code example shows how to use put-provisioned-concurrency-config.
- Amazon CLI
-
To allocate provisioned concurrency
The following
put-provisioned-concurrency-configexample allocates 100 provisioned concurrency for theBLUEalias of the specified function.aws lambda put-provisioned-concurrency-config \ --function-namemy-function\ --qualifierBLUE\ --provisioned-concurrent-executions100Output:
{ "Requested ProvisionedConcurrentExecutions": 100, "Allocated ProvisionedConcurrentExecutions": 0, "Status": "IN_PROGRESS", "LastModified": "2019-11-21T19:32:12+0000" }-
For API details, see PutProvisionedConcurrencyConfig
in Amazon CLI Command Reference.
-
The following code example shows how to use remove-layer-version-permission.
- Amazon CLI
-
To delete layer-version permissions
The following
remove-layer-version-permissionexample deletes permission for an account to configure a layer version.aws lambda remove-layer-version-permission \ --layer-namemy-layer\ --statement-idxaccount\ --version-number1This command produces no output.
For more information, see Amazon Lambda Layers
in the Amazon Lambda Developer Guide. -
For API details, see RemoveLayerVersionPermission
in Amazon CLI Command Reference.
-
The following code example shows how to use remove-permission.
- Amazon CLI
-
To remove permissions from an existing Lambda function
The following
remove-permissionexample removes permission to invoke a function namedmy-function.aws lambda remove-permission \ --function-namemy-function\ --statement-idsnsThis command produces no output.
For more information, see Using Resource-based Policies for Amazon Lambda
in the Amazon Lambda Developer Guide. -
For API details, see RemovePermission
in Amazon CLI Command Reference.
-
The following code example shows how to use tag-resource.
- Amazon CLI
-
To add tags to an existing Lambda function
The following
tag-resourceexample adds a tag with the key nameDEPARTMENTand a value ofDepartment Ato the specified Lambda function.aws lambda tag-resource \ --resourcearn:aws:lambda:us-west-2:123456789012:function:my-function\ --tags"DEPARTMENT=Department A"This command produces no output.
For more information, see Tagging Lambda Functions
in the Amazon Lambda Developer Guide. -
For API details, see TagResource
in Amazon CLI Command Reference.
-
The following code example shows how to use untag-resource.
- Amazon CLI
-
To remove tags from an existing Lambda function
The following
untag-resourceexample removes the tag with the key nameDEPARTMENTtag from themy-functionLambda function.aws lambda untag-resource \ --resourcearn:aws:lambda:us-west-2:123456789012:function:my-function\ --tag-keysDEPARTMENTThis command produces no output.
For more information, see Tagging Lambda Functions
in the Amazon Lambda Developer Guide. -
For API details, see UntagResource
in Amazon CLI Command Reference.
-
The following code example shows how to use update-alias.
- Amazon CLI
-
To update a function alias
The following
update-aliasexample updates the alias namedLIVEto point to version 3 of themy-functionLambda function.aws lambda update-alias \ --function-namemy-function\ --function-version3\ --nameLIVEOutput:
{ "FunctionVersion": "3", "Name": "LIVE", "AliasArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function:LIVE", "RevisionId": "594f41fb-b85f-4c20-95c7-6ca5f2a92c93", "Description": "alias for live version of function" }For more information, see Configuring Amazon Lambda Function Aliases
in the Amazon Lambda Developer Guide. -
For API details, see UpdateAlias
in Amazon CLI Command Reference.
-
The following code example shows how to use update-event-source-mapping.
- Amazon CLI
-
To update the mapping between an event source and an Amazon Lambda function
The following
update-event-source-mappingexample updates the batch size to 8 in the specified mapping.aws lambda update-event-source-mapping \ --uuid"a1b2c3d4-5678-90ab-cdef-11111EXAMPLE"\ --batch-size8Output:
{ "UUID": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE", "StateTransitionReason": "USER_INITIATED", "LastModified": 1569284520.333, "BatchSize": 8, "State": "Updating", "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function", "EventSourceArn": "arn:aws:sqs:us-west-2:123456789012:mySQSqueue" }For more information, see Amazon Lambda Event Source Mapping
in the Amazon Lambda Developer Guide. -
For API details, see UpdateEventSourceMapping
in Amazon CLI Command Reference.
-
The following code example shows how to use update-function-code.
- Amazon CLI
-
To update the code of a Lambda function
The following
update-function-codeexample replaces the code of the unpublished ($LATEST) version of themy-functionfunction with the contents of the specified zip file.aws lambda update-function-code \ --function-namemy-function\ --zip-filefileb://my-function.zipOutput:
{ "FunctionName": "my-function", "LastModified": "2019-09-26T20:28:40.438+0000", "RevisionId": "e52502d4-9320-4688-9cd6-152a6ab7490d", "MemorySize": 256, "Version": "$LATEST", "Role": "arn:aws:iam::123456789012:role/service-role/my-function-role-uy3l9qyq", "Timeout": 3, "Runtime": "nodejs10.x", "TracingConfig": { "Mode": "PassThrough" }, "CodeSha256": "5tT2qgzYUHaqwR716pZ2dpkn/0J1FrzJmlKidWoaCgk=", "Description": "", "VpcConfig": { "SubnetIds": [], "VpcId": "", "SecurityGroupIds": [] }, "CodeSize": 304, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function", "Handler": "index.handler" }For more information, see Amazon Lambda Function Configuration
in the Amazon Lambda Developer Guide. -
For API details, see UpdateFunctionCode
in Amazon CLI Command Reference.
-
The following code example shows how to use update-function-configuration.
- Amazon CLI
-
To modify the configuration of a function
The following
update-function-configurationexample modifies the memory size to be 256 MB for the unpublished ($LATEST) version of themy-functionfunction.aws lambda update-function-configuration \ --function-namemy-function\ --memory-size256Output:
{ "FunctionName": "my-function", "LastModified": "2019-09-26T20:28:40.438+0000", "RevisionId": "e52502d4-9320-4688-9cd6-152a6ab7490d", "MemorySize": 256, "Version": "$LATEST", "Role": "arn:aws:iam::123456789012:role/service-role/my-function-role-uy3l9qyq", "Timeout": 3, "Runtime": "nodejs10.x", "TracingConfig": { "Mode": "PassThrough" }, "CodeSha256": "5tT2qgzYUHaqwR716pZ2dpkn/0J1FrzJmlKidWoaCgk=", "Description": "", "VpcConfig": { "SubnetIds": [], "VpcId": "", "SecurityGroupIds": [] }, "CodeSize": 304, "FunctionArn": "arn:aws:lambda:us-west-2:123456789012:function:my-function", "Handler": "index.handler" }For more information, see Amazon Lambda Function Configuration
in the Amazon Lambda Developer Guide. -
For API details, see UpdateFunctionConfiguration
in Amazon CLI Command Reference.
-
The following code example shows how to use update-function-event-invoke-config.
- Amazon CLI
-
To update an asynchronous invocation configuration
The following
update-function-event-invoke-configexample adds an on-failure destination to the existing asynchronous invocation configuration for the specified function.aws lambda update-function-event-invoke-config \ --function-namemy-function\ --destination-config '{"OnFailure":{"Destination": "arn:aws:sqs:us-east-2:123456789012:destination"}}'Output:
{ "LastModified": 1573687896.493, "FunctionArn": "arn:aws:lambda:us-east-2:123456789012:function:my-function:$LATEST", "MaximumRetryAttempts": 0, "MaximumEventAgeInSeconds": 3600, "DestinationConfig": { "OnSuccess": {}, "OnFailure": { "Destination": "arn:aws:sqs:us-east-2:123456789012:destination" } } }-
For API details, see UpdateFunctionEventInvokeConfig
in Amazon CLI Command Reference.
-