BadRequestException: Failed to fetch secret in Lambda with Node.js

0

I am using the aws-sdk for connecting to a serverless RDS via RDS Data API and I am using the Secrets Manager for the credentials. I have done this before (on another AWS account) and it worked fine. Today I wanted to reproduce this and came up with the following error:

2021-05-27T15:53:30.917Z cf4707a1-1a38-4ae6-9929-856c32a5217c INFO BadRequestException: Failed to fetch secret arn:aws:secretsmanager:us-east-1:xxxxxxxxxxxx:secret:secretRDSxxxxxxxxx-vyJYDL
at Object.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:52:27)
at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/rest_json.js:55:8)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:688:14)
at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:690:12) {
code: 'BadRequestException',
time: 2021-05-27T15:53:30.916Z,
requestId: 'f323d3fe-18c8-46e8-890c-cd1ee41294d5',
statusCode: 400,
retryable: false,
retryDelay: 39.82601622170287
}

I am tyring a simple SQL SELECT here in the following code:
try {
let sqlParams = {
secretArn: process.env.RDSsecretArn,
resourceArn: process.env.RDSresourceArn,
sql: sqlStatement,
database: process.env.RDSdatabase,
includeResultMetadata: true
}
const data = await RDS.executeStatement(sqlParams).promise();
aReturn = data.records[0];

} catch(e) {
console.log(e);
}

The environment variables seem to be correct, as the correct secrectARN is shown in the error message.

Any ideas what this could be or what I can do?

Regards
Daniel

Edited by: danielbrose77 on May 27, 2021 9:14 AM

asked 3 years ago460 views
1 Answer
0

I do not know what the solution has been, because I only played around a little bit with adding another Secret Key, switching back to the orinigal one etc.
I think I did not really change anything here, however it works now.

So might have been a temporary issue, read about that somewhere as well...

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions