Lambda Node.js function Can't Access Aurora MySQL

0

I have a Node.js (ver 16) app in a Lambda Function and I run it on my local machine fine, however when I run the function on AWS I get the following error:

{
  "errorType": "Error",
  "errorMessage": "ER_ACCESS_DENIED_ERROR: Access denied for user 'mailQueue'@'172.31.40.76' (using password: YES)",
  "trace": [
    "Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'mailQueue'@'172.31.40.76' (using password: YES)",
    "    at Handshake.Sequence._packetToError (/var/task/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)",
    "    at Handshake.ErrorPacket (/var/task/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)",
    "    at Protocol._parsePacket (/var/task/node_modules/mysql/lib/protocol/Protocol.js:291:23)",
    "    at Parser._parsePacket (/var/task/node_modules/mysql/lib/protocol/Parser.js:433:10)",
    "    at Parser.write (/var/task/node_modules/mysql/lib/protocol/Parser.js:43:10)",
    "    at Protocol.write (/var/task/node_modules/mysql/lib/protocol/Protocol.js:38:16)",
    "    at Socket.<anonymous> (/var/task/node_modules/mysql/lib/Connection.js:88:28)",
    "    at Socket.<anonymous> (/var/task/node_modules/mysql/lib/Connection.js:526:10)",
    "    at Socket.emit (node:events:527:28)",
    "    at Socket.emit (node:domain:475:12)",
    "    --------------------",
    "    at Protocol._enqueue (/var/task/node_modules/mysql/lib/protocol/Protocol.js:144:48)",
    "    at Protocol.handshake (/var/task/node_modules/mysql/lib/protocol/Protocol.js:51:23)",
    "    at PoolConnection.connect (/var/task/node_modules/mysql/lib/Connection.js:116:18)",
    "    at Pool.getConnection (/var/task/node_modules/mysql/lib/Pool.js:48:16)",
    "    at Runtime.exports.handler (/var/task/index.js:15:10)",
    "    at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1028:29)"
  ]
}

The Aurora Security group allows connections from 172.31.0.0/16 and the reachability analyser gives it the ok.

So it appears to be mySQL having issues. The user appears to have correct permissions from any host.

SHOW GRANTS FOR 'mailQueue'

> GRANT USAGE ON *.* TO `mailQueue`@`%`
> GRANT ALL PRIVILEGES ON `emailTransactions`.* TO `mailQueue`@`%` WITH GRANT OPTION

Any suggestions from anyone?

Confirmed all settings with manuals and searched the net, I'm stumped.

已提問 1 年前檢視次數 339 次
2 個答案
0

The error suggests your lambda is able to reach Aurora but not authenticate. I know you have already verified everything, but do recheck the credentials Lambda is using to access Aurora

已回答 1 年前
0

For Troubleshooting purposes , you could deploy an EC2 instance in same subnet that is allowed by Aurora MySQL Security Group, attempt to connect using the mysql client with the credentials you are using within your lambda or if using IAM authentication you can follow steps here

AWS
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南