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.

질문됨 일 년 전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

답변함 일 년 전
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
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠