In my application,I will input data to invoke my lambda function,how can I do it? Thanks a lot.
The Payload parameter of the invoke function might be what you are looking for.
The format is "bytes or seekable file-like object" which means a bytes string, or an open filehandle or perhaps a BytesIO?
This works for me:
import boto3
import json
import pprint
params = {"day": "20220410"}
client = boto3.client('lambda')
response = client.invoke(
FunctionName='my_lambda_function',
InvocationType='RequestResponse',
Payload=json.dumps(params).encode(),
)
pprint.pp(response['Payload'].read())
The lambda receives the params in the event dictionary:
def my_lambda_function(event, context):
day = event['day']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With