d33tah
d33tah

Reputation: 11569

Access Lambda logs from an asynchronous call?

I'd like to run my delete_me function and get its output. I tried the following command:

aws lambda invoke \
--invocation-type Event \
--function-name delete_me \
--region us-west-2 \
--log-type Tail \
--payload '{"key1":"value1", "key2":"value2", "key3":"value3"}' outputfile.txt 

And got the following output:

{
    "StatusCode": 202
}

Am I doing something wrong? How can I access the logs?

Upvotes: 0

Views: 216

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269826

From the invoke() documentation:

response = client.invoke(
    FunctionName='string',
    InvocationType='Event'|'RequestResponse'|'DryRun',
    LogType='None'|'Tail',
    ClientContext='string',
    Payload=b'bytes'|file,
    Qualifier='string'
)

Returns:

{
    'StatusCode': 123,
    'FunctionError': 'string',
    'LogResult': 'string',
    'Payload': StreamingBody(),
    'ExecutedVersion': 'string'
}

Payload (StreamingBody) --

It is the JSON representation of the object returned by the Lambda function. This is present only if the invocation type is RequestResponse

So, add invocationType='RequestResponse' to your call.

Upvotes: 0

Related Questions