Table of Contents
Lambda.
Client
¶A low-level client representing AWS Lambda:
client = session.create_client('lambda')
These are the available methods:
add_permission()
can_paginate()
create_event_source_mapping()
create_function()
delete_event_source_mapping()
delete_function()
generate_presigned_url()
get_event_source_mapping()
get_function()
get_function_configuration()
get_paginator()
get_policy()
get_waiter()
invoke()
invoke_async()
list_event_source_mappings()
list_functions()
remove_permission()
update_event_source_mapping()
update_function_code()
update_function_configuration()
add_permission
(**kwargs)¶Adds a permission to the access policy associated with the specified AWS Lambda function. In a "push event" model, the access policy attached to the Lambda function grants Amazon S3 or a user application permission for the Lambda lambda:Invoke
action. For information about the push model, see AWS Lambda: How it Works . Each Lambda function has one access policy associated with it. You can use the AddPermission
API to add a permission to the policy. You have one access policy but it can have multiple permission statements.
This operation requires permission for the lambda:AddPermission
action.
Request Syntax
response = client.add_permission(
FunctionName='string',
StatementId='string',
Action='string',
Principal='string',
SourceArn='string',
SourceAccount='string'
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'Statement': 'string'
}
Response Structure
|
can_paginate
(operation_name)¶Check if an operation can be paginated.
Parameters: | operation_name (string) -- The operation name. This is the same name
as the method name on the client. For example, if the
method name is create_foo , and you'd normally invoke the
operation as client.create_foo(**kwargs) , if the
create_foo operation can be paginated, you can use the
call client.get_paginator("create_foo") . |
---|---|
Returns: | True if the operation can be paginated,
False otherwise. |
create_event_source_mapping
(**kwargs)¶Identifies a stream as an event source for a Lambda function. It can be either an Amazon Kinesis stream or an Amazon DynamoDB stream. AWS Lambda invokes the specified function when records are posted to the stream.
This is the pull model, where AWS Lambda invokes the function. For more information, go to AWS Lambda: How it Works in the AWS Lambda Developer Guide .
This association between an Amazon Kinesis stream and a Lambda function is called the event source mapping. You provide the configuration information (for example, which stream to read from and which Lambda function to invoke) for the event source mapping in the request body.
Each event source, such as an Amazon Kinesis or a DynamoDB stream, can be associated with multiple AWS Lambda function. A given Lambda function can be associated with multiple AWS event sources.
This operation requires permission for the lambda:CreateEventSourceMapping
action.
Request Syntax
response = client.create_event_source_mapping(
EventSourceArn='string',
FunctionName='string',
Enabled=True|False,
BatchSize=123,
StartingPosition='TRIM_HORIZON'|'LATEST'
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'UUID': 'string',
'BatchSize': 123,
'EventSourceArn': 'string',
'FunctionArn': 'string',
'LastModified': datetime(2015, 1, 1),
'LastProcessingResult': 'string',
'State': 'string',
'StateTransitionReason': 'string'
}
Response Structure
|
create_function
(**kwargs)¶Creates a new Lambda function. The function metadata is created from the request parameters, and the code for the function is provided by a .zip file in the request body. If the function name already exists, the operation will fail. Note that the function name is case-sensitive.
This operation requires permission for the lambda:CreateFunction
action.
Request Syntax
response = client.create_function(
FunctionName='string',
Runtime='nodejs'|'java8',
Role='string',
Handler='string',
Description='string',
Timeout=123,
MemorySize=123,
Code={
'ZipFile': b'bytes',
'S3Bucket': 'string',
'S3Key': 'string',
'S3ObjectVersion': 'string'
}
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'FunctionName': 'string',
'FunctionArn': 'string',
'Runtime': 'nodejs'|'java8',
'Role': 'string',
'Handler': 'string',
'CodeSize': 123,
'Description': 'string',
'Timeout': 123,
'MemorySize': 123,
'LastModified': 'string'
}
Response Structure
|
delete_event_source_mapping
(**kwargs)¶Removes an event source mapping. This means AWS Lambda will no longer invoke the function for events in the associated source.
This operation requires permission for the lambda:DeleteEventSourceMapping
action.
Request Syntax
response = client.delete_event_source_mapping(
UUID='string'
)
Parameters: | UUID (string) -- [REQUIRED] The event source mapping ID. |
---|---|
Return type: | dict |
Returns: | Response Syntax{
'UUID': 'string',
'BatchSize': 123,
'EventSourceArn': 'string',
'FunctionArn': 'string',
'LastModified': datetime(2015, 1, 1),
'LastProcessingResult': 'string',
'State': 'string',
'StateTransitionReason': 'string'
}
Response Structure
|
delete_function
(**kwargs)¶Deletes the specified Lambda function code and configuration.
When you delete a function the associated access policy is also deleted. You will need to delete the event source mappings explicitly.
This operation requires permission for the lambda:DeleteFunction
action.
Request Syntax
response = client.delete_function(
FunctionName='string'
)
Parameters: | FunctionName (string) -- [REQUIRED] The Lambda function to delete. You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length. |
---|---|
Returns: | None |
generate_presigned_url
(ClientMethod, Params=None, ExpiresIn=3600, HttpMethod=None)¶Generate a presigned url given a client, its method, and arguments
Parameters: |
|
---|---|
Returns: | The presigned url |
get_event_source_mapping
(**kwargs)¶Returns configuration information for the specified event source mapping (see CreateEventSourceMapping ).
This operation requires permission for the lambda:GetEventSourceMapping
action.
Request Syntax
response = client.get_event_source_mapping(
UUID='string'
)
Parameters: | UUID (string) -- [REQUIRED] The AWS Lambda assigned ID of the event source mapping. |
---|---|
Return type: | dict |
Returns: | Response Syntax{
'UUID': 'string',
'BatchSize': 123,
'EventSourceArn': 'string',
'FunctionArn': 'string',
'LastModified': datetime(2015, 1, 1),
'LastProcessingResult': 'string',
'State': 'string',
'StateTransitionReason': 'string'
}
Response Structure
|
get_function
(**kwargs)¶Returns the configuration information of the Lambda function and a presigned URL link to the .zip file you uploaded with CreateFunction so you can download the .zip file. Note that the URL is valid for up to 10 minutes. The configuration information is the same information you provided as parameters when uploading the function.
This operation requires permission for the lambda:GetFunction
action.
Request Syntax
response = client.get_function(
FunctionName='string'
)
Parameters: | FunctionName (string) -- [REQUIRED] The Lambda function name. You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length. |
---|---|
Return type: | dict |
Returns: | Response Syntax{
'Configuration': {
'FunctionName': 'string',
'FunctionArn': 'string',
'Runtime': 'nodejs'|'java8',
'Role': 'string',
'Handler': 'string',
'CodeSize': 123,
'Description': 'string',
'Timeout': 123,
'MemorySize': 123,
'LastModified': 'string'
},
'Code': {
'RepositoryType': 'string',
'Location': 'string'
}
}
Response Structure
|
get_function_configuration
(**kwargs)¶Returns the configuration information of the Lambda function. This the same information you provided as parameters when uploading the function by using CreateFunction .
This operation requires permission for the lambda:GetFunctionConfiguration
operation.
Request Syntax
response = client.get_function_configuration(
FunctionName='string'
)
Parameters: | FunctionName (string) -- [REQUIRED] The name of the Lambda function for which you want to retrieve the configuration information. You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length. |
---|---|
Return type: | dict |
Returns: | Response Syntax{
'FunctionName': 'string',
'FunctionArn': 'string',
'Runtime': 'nodejs'|'java8',
'Role': 'string',
'Handler': 'string',
'CodeSize': 123,
'Description': 'string',
'Timeout': 123,
'MemorySize': 123,
'LastModified': 'string'
}
Response Structure
|
get_paginator
(operation_name)¶Create a paginator for an operation.
Parameters: | operation_name (string) -- The operation name. This is the same name
as the method name on the client. For example, if the
method name is create_foo , and you'd normally invoke the
operation as client.create_foo(**kwargs) , if the
create_foo operation can be paginated, you can use the
call client.get_paginator("create_foo") . |
---|---|
Raises OperationNotPageableError: | |
Raised if the operation is not
pageable. You can use the client.can_paginate method to
check if an operation is pageable. |
|
Return type: | L{botocore.paginate.Paginator} |
Returns: | A paginator object. |
get_policy
(**kwargs)¶Returns the access policy, containing a list of permissions granted via the AddPermission
API, associated with the specified bucket.
You need permission for the lambda:GetPolicy action.
Request Syntax
response = client.get_policy(
FunctionName='string'
)
Parameters: | FunctionName (string) -- [REQUIRED] Function name whose access policy you want to retrieve. You can specify an unqualified function name (for example, "Thumbnail") or you can specify Amazon Resource Name (ARN) of the function (for example, "arn:aws:lambda:us-west-2:account-id:function:ThumbNail"). AWS Lambda also allows you to specify only the account ID qualifier (for example, "account-id:Thumbnail"). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 character in length. |
---|---|
Return type: | dict |
Returns: | Response Syntax{
'Policy': 'string'
}
Response Structure
|
get_waiter
(waiter_name)¶invoke
(**kwargs)¶Invokes a specified Lambda function.
This operation requires permission for the lambda:InvokeFunction
action.
Request Syntax
response = client.invoke(
FunctionName='string',
InvocationType='Event'|'RequestResponse'|'DryRun',
LogType='None'|'Tail',
ClientContext='string',
Payload=b'bytes'
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'StatusCode': 123,
'FunctionError': 'string',
'LogResult': 'string',
'Payload': b'bytes'
}
Response Structure
|
invoke_async
(**kwargs)¶Warning
This API is deprecated. We recommend you use Invoke
API (see Invoke ).
Submits an invocation request to AWS Lambda. Upon receiving the request, Lambda executes the specified function asynchronously. To see the logs generated by the Lambda function execution, see the CloudWatch logs console.
This operation requires permission for the lambda:InvokeFunction
action.
Request Syntax
response = client.invoke_async(
FunctionName='string',
InvokeArgs=b'bytes'
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'Status': 123
}
Response Structure
|
list_event_source_mappings
(**kwargs)¶Returns a list of event source mappings you created using the CreateEventSourceMapping
(see CreateEventSourceMapping ), where you identify a stream as an event source. This list does not include Amazon S3 event sources.
For each mapping, the API returns configuration information. You can optionally specify filters to retrieve specific event source mappings.
This operation requires permission for the lambda:ListEventSourceMappings
action.
Request Syntax
response = client.list_event_source_mappings(
EventSourceArn='string',
FunctionName='string',
Marker='string',
MaxItems=123
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'NextMarker': 'string',
'EventSourceMappings': [
{
'UUID': 'string',
'BatchSize': 123,
'EventSourceArn': 'string',
'FunctionArn': 'string',
'LastModified': datetime(2015, 1, 1),
'LastProcessingResult': 'string',
'State': 'string',
'StateTransitionReason': 'string'
},
]
}
Response Structure
|
list_functions
(**kwargs)¶Returns a list of your Lambda functions. For each function, the response includes the function configuration information. You must use GetFunction to retrieve the code for your function.
This operation requires permission for the lambda:ListFunctions
action.
Request Syntax
response = client.list_functions(
Marker='string',
MaxItems=123
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'NextMarker': 'string',
'Functions': [
{
'FunctionName': 'string',
'FunctionArn': 'string',
'Runtime': 'nodejs'|'java8',
'Role': 'string',
'Handler': 'string',
'CodeSize': 123,
'Description': 'string',
'Timeout': 123,
'MemorySize': 123,
'LastModified': 'string'
},
]
}
Response Structure
|
remove_permission
(**kwargs)¶You can remove individual permissions from an access policy associated with a Lambda function by providing a Statement ID.
Note that removal of a permission will cause an active event source to lose permission to the function.
You need permission for the lambda:RemovePermission
action.
Request Syntax
response = client.remove_permission(
FunctionName='string',
StatementId='string'
)
Parameters: |
|
---|---|
Returns: | None |
update_event_source_mapping
(**kwargs)¶You can update an event source mapping. This is useful if you want to change the parameters of the existing mapping without losing your position in the stream. You can change which function will receive the stream records, but to change the stream itself, you must create a new mapping.
This operation requires permission for the lambda:UpdateEventSourceMapping
action.
Request Syntax
response = client.update_event_source_mapping(
UUID='string',
FunctionName='string',
Enabled=True|False,
BatchSize=123
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'UUID': 'string',
'BatchSize': 123,
'EventSourceArn': 'string',
'FunctionArn': 'string',
'LastModified': datetime(2015, 1, 1),
'LastProcessingResult': 'string',
'State': 'string',
'StateTransitionReason': 'string'
}
Response Structure
|
update_function_code
(**kwargs)¶Updates the code for the specified Lambda function. This operation must only be used on an existing Lambda function and cannot be used to update the function configuration.
This operation requires permission for the lambda:UpdateFunctionCode
action.
Request Syntax
response = client.update_function_code(
FunctionName='string',
ZipFile=b'bytes',
S3Bucket='string',
S3Key='string',
S3ObjectVersion='string'
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'FunctionName': 'string',
'FunctionArn': 'string',
'Runtime': 'nodejs'|'java8',
'Role': 'string',
'Handler': 'string',
'CodeSize': 123,
'Description': 'string',
'Timeout': 123,
'MemorySize': 123,
'LastModified': 'string'
}
Response Structure
|
update_function_configuration
(**kwargs)¶Updates the configuration parameters for the specified Lambda function by using the values provided in the request. You provide only the parameters you want to change. This operation must only be used on an existing Lambda function and cannot be used to update the function's code.
This operation requires permission for the lambda:UpdateFunctionConfiguration
action.
Request Syntax
response = client.update_function_configuration(
FunctionName='string',
Role='string',
Handler='string',
Description='string',
Timeout=123,
MemorySize=123
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'FunctionName': 'string',
'FunctionArn': 'string',
'Runtime': 'nodejs'|'java8',
'Role': 'string',
'Handler': 'string',
'CodeSize': 123,
'Description': 'string',
'Timeout': 123,
'MemorySize': 123,
'LastModified': 'string'
}
Response Structure
|
The available paginators are:
Lambda.Paginator.
list_event_source_mappings
¶paginator = client.get_paginator('list_event_source_mappings')
paginate
(**kwargs)¶Creates an iterator that will paginate through responses from Lambda.Client.list_event_source_mappings()
.
Request Syntax
response_iterator = paginator.paginate(
EventSourceArn='string',
FunctionName='string',
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
Parameters: |
|
---|---|
Return type: | dict |
Returns: | Response Syntax {
'EventSourceMappings': [
{
'UUID': 'string',
'BatchSize': 123,
'EventSourceArn': 'string',
'FunctionArn': 'string',
'LastModified': datetime(2015, 1, 1),
'LastProcessingResult': 'string',
'State': 'string',
'StateTransitionReason': 'string'
},
],
'NextToken': 'string'
}
Response Structure
|
Lambda.Paginator.
list_functions
¶paginator = client.get_paginator('list_functions')
paginate
(**kwargs)¶Creates an iterator that will paginate through responses from Lambda.Client.list_functions()
.
Request Syntax
response_iterator = paginator.paginate(
PaginationConfig={
'MaxItems': 123,
'PageSize': 123,
'StartingToken': 'string'
}
)
Parameters: | PaginationConfig (dict) -- A dictionary that provides parameters to control pagination.
|
---|---|
Return type: | dict |
Returns: | Response Syntax{
'Functions': [
{
'FunctionName': 'string',
'FunctionArn': 'string',
'Runtime': 'nodejs'|'java8',
'Role': 'string',
'Handler': 'string',
'CodeSize': 123,
'Description': 'string',
'Timeout': 123,
'MemorySize': 123,
'LastModified': 'string'
},
],
'NextToken': 'string'
}
Response Structure
|