2
votes

i am trying to integrate lambda and rest api gateway endpoint using aws cli and running the following command but getting follwing error

aws apigateway put-integration  --region us-west-2 --rest-api-id 91b73m5i10  --resource-id pjg2ac --http-method GET --type AWS --integration-http-method GET --uri arn:aws:apigateway:us-west-2:lambda:path/apigateway/functions/arn:aws:lambda:us-west-2:xxxxx:function:sendFile_Trips_divyanayan/invocations

An error occurred (NotFoundException) when calling the PutIntegration operation: Invalid Method identifier specified

Saw this related article but was not of much help

Create api-gateway lambda integration using aws-cli

1

1 Answers

0
votes

The error is self explanatory. It likely that your ApiGateway endpoint doesn't have GET method on that resource.

Please add the same and then try to run the above command.

You might need to add the --credentials parameter which is ARN for IAM role which allows this integration with lambda function.

You also need to change --integration-http-method to POST (This is the default integration method between apigateway- lambda.

aws apigateway put-integration  --region us-west-2 --rest-api-id 91b73m5i10  --resource-id pjg2ac --http-method GET --type AWS_PROXY --integration-http-method POST --uri arn:aws:apigateway:us-west-2:lambda:path//2015-03-31/functions/arn:aws:lambda:us-west-2:xxxxxxxx:function:sendFile_Trips_divyanayan/invocations --credentials arn:aws:iam::xxxxxxxx:role/lambda-role

Also the role that is given in the credentials should have below thins in trusted relationships (Principal)

    {
        "Version": "2012-10-17",
        "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
            "Service": [
                "apigateway.amazonaws.com",
                "logs.amazonaws.com",
                "lambda.amazonaws.com"
            ]
        },
        "Action": "sts:AssumeRole"
    }
  ]
}

Note: Dont expose the accountId while asking questions on external forums.