AWS CLI execute a lambda function issue

Viewed 15336

I'm trying to invoke a lambda function from my AWS CLI in windows 10. I've done previously a configuration of my client thru AWS configure.

The command used is:

aws lambda invoke \
    --function-name arn:aws:lambda:us-east-1:111111111:function:xxx \
    --invocation-type RequestResponse

but my system is returning an error aws: error: too few arguments, as shown below:

enter image description here

Could you guys guide me to succeed in this execution?

thanks

4 Answers

In case you are integrating with Jenkins(Windows) and dont want to use Lambda plugin. Lambda plugin is somehow not taking credentials I set in jenkins binding.

Prepare payload first. I have taken parameters from user.

@echo off
@echo {> payload.json
@echo  "type": "RequestType",>> payload.json
@echo  "siteCode": "%SiteCode%",>> payload.json
@echo  "siteDesc": "%SiteDesc%",>> payload.json
@echo }>> payload.json

Invoke lambda using aws cli.

aws lambda invoke --function-name "FuntionName" --invocation-type RequestResponse --region us-zone-id --log-type Tail --payload file://payload.json response.json

You can print response using type command.

type response.json

AWS CLI version details

aws-cli/2.1.13 Python/3.7.9 Windows/10 exe/AMD64 prompt/off

Invoke Lambda cmd, Payload needs to be Base64 encoded (https://www.base64decode.org/), you can also install plugin if needed

aws configure // If applicable perform the aws configure
aws lambda invoke --function-name test_details:DEV  --payload #yHw response_test.json

success response

{
    "StatusCode": 200,
    "ExecutedVersion": "18"
}

The response_test.json should be generated under same path. Ref document https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lambda/invoke.html

Related