The following code example shows how to list Lambda functions.
Note
The source code for these examples is in the AWS Code Examples GitHub repository. Have feedback on a code example? Create an Issue in the code examples repo.
SDK for Python (Boto3)
To learn how to set up and run this example, see GitHub.
class LambdaWrapper:
def __init__(self, lambda_client, iam_resource):
self.lambda_client = lambda_client
self.iam_resource = iam_resource
def list_functions(self):
"""
Lists the Lambda functions for the current account.
"""
try:
func_paginator = self.lambda_client.get_paginator('list_functions')
for func_page in func_paginator.paginate():
for func in func_page['Functions']:
print(func['FunctionName'])
desc = func.get('Description')
if desc:
print(f"\t{desc}")
print(f"\t{func['Runtime']}: {func['Handler']}")
except ClientError as err:
logger.error(
"Couldn't list functions. Here's why: %s: %s",
err.response['Error']['Code'], err.response['Error']['Message'])
raise
- For API details, see ListFunctions in AWS SDK for Python (Boto3) API Reference.
For a complete list of AWS SDK developer guides and code examples, see Using Lambda with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.