1
votes

I'm making a call to the AWS Lambda CLI to invoke my function. I want to get the function response (Payload) as part of my return object so I'm passing --invocation-type RequestResponse. With that, I'm still only getting the function output in my output file (which I actually don't care about). I want it as part of the object returned from this CLI call but there I only get the LogResult and the StatusCode.

{
    "LogResult": "encoded blah blah blah", 
    "StatusCode": 200
}

Am I making a typo in my command or am I missing something? How can I get the function output (Payload) as part of the object returned from this CLI call?

aws lambda invoke --function-name myFunction --invocation-type RequestResponse --log-type Tail --payload {} --region us-east-1 testoutput.txt
1
Please verify you have the latest version of the AWS CLI tool with the command aws --version - Mark B
Running version 1.11.129, which is of course outdated, but when I try to upgrade with pip install awscli --upgrade --user I have that same version. Not sure how to get up to 1.11.84 (I'm on Amazon Linux). - Brady Dowling
1.11.129 is a neweer version than 1.11.84. 129 is greater than 84 - Mark B
😬 good point. Good ole semantic versioning ;) So I'm back to square one, not sure what's causing this. - Brady Dowling

1 Answers

3
votes

I want to get the function response (Payload) as part of my return object so I'm passing --invocation-type RequestResponse

That isn't what that option does. Also, specifying this is essentially a no-op, since RequestResponse is already the default. The alternative (Event) tells Lambda to run the function asynchronously (from your perspective) without waiting for it to complete. It's not about how the response is collected or returned, but rather whether the response is completely discarded because your invocation request is detached from the running function and returns immediately.

I'm still only getting the function output in my output file

That's exactly how it is supposed to work. That's why you have to specify an output file. The function output is written to that file, only.