Paginators#. Paginators are available on a client instance via the get_paginator method. For more detailed instructions and examples on the usage of paginators, see the paginators user guide.. The available paginators are:
Quickstart#. This guide details the steps needed to install or update the AWS SDK for Python. The SDK is composed of two key Python packages: Botocore (the library providing the low-level functionality shared between the Python SDK and the AWS CLI) and Boto3 (the package implementing the Python SDK itself).
An asynchronously executed AWS Lambda function doesn't return the result of execution. If an asynchronous invocation request is successful (i.e. there were no errors due to permissions, etc), AWS Lambda immediately returns the HTTP status code 202 ACCEPTED and bears no further responsibility for communicating any information about the outcome of this asynchronous invocation.
From the documentation of AWS Lambda Invoke action:
Response Syntax
HTTP/1.1 StatusCode X-Amz-Function-Error: FunctionError X-Amz-Log-Result: LogResult PayloadResponse Elements
If the action is successful, the service sends back the following HTTP response.
StatusCode
The HTTP status code will be in the 200 range for successful request. For the
invocation type this status code will be 200. For theRequestResponseinvocation type this status code will be 202. For theEventinvocation type the status code will be 204.DryRun[...]
The response returns the following as the HTTP body.
Payload
It is the JSON representation of the object returned by the Lambda function. This is present only if the invocation type is
.RequestResponse
If you don't want to update your lambda function, just simulate APIGateway event object by boto3 client:
If your api looks like (ex: https://linktolambda/{id})https://linktolambda/123456
You will invoke with this code:
payload = { "pathParameters": { "id":"123456" } }
result = client.invoke(FunctionName=conf.lambda_function_name,
InvocationType='RequestResponse',
Payload=json.dumps(payload))
Or your API look like https://linktolambda?id=123456
payload = { "queryStringParameters": { "id":"123456" } }
result = client.invoke(FunctionName=conf.lambda_function_name,
InvocationType='RequestResponse',
Payload=json.dumps(payload))
Manuel,
as mentioned, the return info is inside the Payload element in the returned json. Payload is a boto3 object type that you need to access it's contents through it's read() method.
The code I used to get the python dictionary that I return from my lambda functions is this:
payload = json.loads(response['Payload'].read())
statusCode = payload.get('statusCode')
message = payload.get('message')
results = payload.get('results')