Jesus is Lord
Jesus is Lord

Reputation: 15409

CLI - Execution failed due to configuration error: Invalid permissions on Lambda function

I ran the following from the CLI:

aws lambda update-function-code --function-name awsLambdaHelloWorld --zip-file fileb://temp.zip

aws apigateway get-resources --rest-api-id XXXXXX

aws apigateway get-method --rest-api-id XXXXXX --resource-id XXXXXX --http-method POST

aws apigateway put-integration --rest-api-id XXXXXX --resource-id 2oycdcu7ge \
--http-method POST --type AWS --integration-http-method POST \
--uri arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1: XXXXXX:function:awsLambdaHelloWorld/invocations \
--credentials arn:aws:iam:: XXXXXX:role/service-role/sandbox-role-XXXXXX

I click "Test" in the API Gateway AWS UI.

I get the following error:

Tue Jun 09 19:24:11 UTC 2020 : Execution failed due to configuration error: Invalid permissions on Lambda function
Tue Jun 09 19:24:11 UTC 2020 : Method completed with status: 500

I tried this:

aws lambda add-permission --function-name awsLambdaHelloWorld \
--action lambda:InvokeFunction --statement-id apigateway \
--principal apigateway.amazonaws.com

I still get the error.

What do I need to do from the CLI to fix this?

The Lambda function and API Gateway share the same role. If I give that role Administrator Access, it gets past that error.

Upvotes: 0

Views: 484

Answers (1)

Jesus is Lord
Jesus is Lord

Reputation: 15409

Adding the following policy to the role of the API Gateway worked, per this article.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "lambda:InvokeFunction",
            "Resource": "*"
        }
    ]
}

Upvotes: 1

Related Questions