AWS Lambda throw unknow error

Describe the issue/error/question

When the Lambda node execute, it will throw unknow error as show below. The AWS Credential works fine as it was able to get the list to functions. I also manage to get the correct response in Postman using the same IAM account and same Lambda function.

What is the error message (if any)?

Share the output returned by the last node

NodeApiError: UNKNOWN ERROR - check the detailed error for more information
    at Object.awsApiRequest (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Aws/GenericFunctions.js:23:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.awsApiRequestREST (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Aws/GenericFunctions.js:28:22)
    at async Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Aws/AwsLambda.node.js:159:38)
    at async Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:658:28)
    at async /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:585:53

Information on your n8n setup

  • **n8n version:0.202.1
  • **Database you’re using (default: SQLite): postgresql
  • **Running n8n with the execution process [own(default), main]:own
  • **Running n8n via [Docker, npm, n8n.cloud, desktop app]:docker

Hi @butbut, welcome to the community!

I am sorry to hear you’re having trouble. What does the error message above the “Stack” field from your screenshot say?


It say ERROR: UNKNOWN ERROR - check the detailed error for more information

Oh, that’s not a helpful error message of course :frowning:

Anything more useful in your server logs? If not, could you share your Lambda node (simply select it on your n8n canvas and press Ctrl+C to copy it, then insert the result here in the forum) and confirm how your function looks like?

Thank you!

Hello, I am new to this community.

I am facing the exact same issue.

n8n AWS lambda execution error screenshot

n8n workflow screenshot

Stack message

NodeApiError: UNKNOWN ERROR - check the detailed error for more information
    at Object.awsApiRequest (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Aws/GenericFunctions.js:23:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Object.awsApiRequestREST (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Aws/GenericFunctions.js:28:22)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Aws/AwsLambda.node.js:159:38)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:658:28)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:585:53

Server Logs

Initializing n8n process
n8n ready on 0.0.0.0, port 5678
Version: 0.206.1

Editor is now accessible via:
http://localhost:5678/
Error "Error: not a number" when casting workflow ID to a number
Error "Error: not a number" when casting workflow ID to a number
Error "Error: not a number" when casting workflow ID to a number

Lambda Node (Ctrl+C on lambda node)

AWS Policy Permissions

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "lambda:InvokeFunction",
            "Resource": "arn:aws:lambda:ap-south-1:<AccountID>:function:GetLightsailInstanceState"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": "lambda:ListFunctions",
            "Resource": "*"
        }
    ]
}

I tested the function from AWS Console and it works as expected and I tested the above policy in AWS policy simulator and it allows invocation of function “GetLightsailInstanceState”.

Hey @courtney, welcome to the community :tada:

I just tested your workflow on the current version of n8n (0.207.1) and it’s working fine for me when using a valid Qualifier:

This is a dummy function I’ve just created in my AWS account:

Is there a chance you might simply be using an invalid Qualifier? Changing mine would lead to the error you have reported:

Using a valid value such as 1 or $LATEST would resolve the problem.

If that’s not it, can you confirm how exactly you have configured your Lambda function so I can try and reproduce the problem?

Hey @MutedJam - Thanks for your response and anaysis.

The issue was indeed related to qualifier and the n8n permissions policy in AWS.

I added a version & an alias to the function in AWS and allowed n8n user in AWS to invoke that alias’ed function

n8n user permissions policy on AWS

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "lambda:InvokeFunction",
            "Resource": [
                "arn:aws:lambda:ap-south-1:<account_id>:function:GetLightsailInstanceState:v2"
            ]
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": "lambda:ListFunctions",
            "Resource": "*"
        }
    ]
}

After that I corrected the Qualifier in the lambda node as suggested and it worked.

Thanks for your help.

2 Likes

Sweet, glad to hear this works! Thanks so much for confirming :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.