The following code example shows how to get a Lambda function.
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 get_function(self, function_name):
"""
Gets data about a Lambda function.
:param function_name: The name of the function.
:return: The function data.
"""
response = None
try:
response = self.lambda_client.get_function(FunctionName=function_name)
except ClientError as err:
if err.response['Error']['Code'] == 'ResourceNotFoundException':
logger.info("Function %s does not exist.", function_name)
else:
logger.error(
"Couldn't get function %s. Here's why: %s: %s", function_name,
err.response['Error']['Code'], err.response['Error']['Message'])
raise
return response
- For API details, see GetFunction 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.