How to fix timeout error that I am facing while connecting to AWS Secret Manager?

45 Views Asked by At

I have wrote the following code in the AWS console and it worked.

const AWS = require('aws-sdk')


const SM = new AWS.SecretsManager
exports.getWalletPrivateKey = async()=>{
    console.log("Wallet Private Key",process.env.wallet_private_key_secret_name)
    const secretData = await SM.getSecretValue({
        SecretId: process.env.wallet_private_key_secret_name
    }).promise()
    
    const replaced = secretData.SecretString.replace(/['"{}]/g,"");
    const key_pair = replaced.split(",")
   
    const splitted_key_pair = key_pair[0].split(":")
  
    if(splitted_key_pair[0]==process.env.secret_key)
        return splitted_key_pair[1]
    
}

Then I tried the same code adding the following part in my local PC but it is not working.-

AWS.config.update({
  accessKeyId: process.env.AWS_ACCESSKEY,
  secretAccessKey: process.env.AWS_SECRETKEY,
  region: 'us-east-1', // Replace this with your desired AWS region
});

I am getting this error -

node:internal/process/promises:289 triggerUncaughtException(err, true /* fromPromise */); ^

AggregateError [ETIMEDOUT]: 
    at internalConnectMultiple (node:net:1116:18)
    at internalConnectMultiple (node:net:1184:5)
    at Timeout.internalConnectMultipleTimeout (node:net:1707:5)
    at listOnTimeout (node:internal/timers:575:11)
    at process.processTimers (node:internal/timers:514:7) {   code: 'TimeoutError',   message: null,   time: 2024-03-22T06:48:12.393Z,   region: 'us-east-1',   hostname: 'secretsmanager.us-east-1.amazonaws.com',   retryable: true,   [errors]: [
    Error: connect ETIMEDOUT 18.209.193.36:443
        at createConnectionError (node:net:1643:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1702:38)
        at listOnTimeout (node:internal/timers:575:11)
        at process.processTimers (node:internal/timers:514:7) {
      errno: -110,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '18.209.193.36',
      port: 443
    },
    Error: connect ENETUNREACH 2600:1f18:2544:ce04:cf54:e48d:ded:b474:443 - Local (:::0)
        at internalConnectMultiple (node:net:1180:16)
        at Timeout.internalConnectMultipleTimeout (node:net:1707:5)
        at listOnTimeout (node:internal/timers:575:11)
        at process.processTimers (node:internal/timers:514:7) {
      errno: -101,
      code: 'ENETUNREACH',
      syscall: 'connect',
      address: '2600:1f18:2544:ce04:cf54:e48d:ded:b474',
      port: 443
    },
    Error: connect ETIMEDOUT 54.89.26.226:443
        at createConnectionError (node:net:1643:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1702:38)
        at listOnTimeout (node:internal/timers:575:11)
        at process.processTimers (node:internal/timers:514:7) {
      errno: -110,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '54.89.26.226',
      port: 443
    },
    Error: connect ENETUNREACH 2600:1f18:2544:ce03:e601:1b91:b5a9:ade2:443 - Local (:::0)
        at internalConnectMultiple (node:net:1180:16)
        at Timeout.internalConnectMultipleTimeout (node:net:1707:5)
        at listOnTimeout (node:internal/timers:575:11)
        at process.processTimers (node:internal/timers:514:7) {
      errno: -101,
      code: 'ENETUNREACH',
      syscall: 'connect',
      address: '2600:1f18:2544:ce03:e601:1b91:b5a9:ade2',
      port: 443
    },
    Error: connect ETIMEDOUT 34.231.78.94:443
        at createConnectionError (node:net:1643:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1702:38)
        at listOnTimeout (node:internal/timers:575:11)
        at process.processTimers (node:internal/timers:514:7) {
      errno: -110,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '34.231.78.94',
      port: 443
    },
    Error: connect ENETUNREACH 2600:1f18:2544:ce02:c30c:bd57:b796:8cb4:443 - Local (:::0)
        at internalConnectMultiple (node:net:1180:16)
        at Timeout.internalConnectMultipleTimeout (node:net:1707:5)
        at listOnTimeout (node:internal/timers:575:11)
        at process.processTimers (node:internal/timers:514:7) {
      errno: -101,
      code: 'ENETUNREACH',
      syscall: 'connect',
      address: '2600:1f18:2544:ce02:c30c:bd57:b796:8cb4',
      port: 443
    },
    Error: connect ETIMEDOUT 34.227.248.3:443
        at createConnectionError (node:net:1643:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1702:38)
        at listOnTimeout (node:internal/timers:575:11)
        at process.processTimers (node:internal/timers:514:7) {
      errno: -110,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '34.227.248.3',
      port: 443
    },
    Error: connect ENETUNREACH 2600:1f18:2544:ce01:7707:2a5c:d55b:b060:443 - Local (:::0)
        at internalConnectMultiple (node:net:1180:16)
        at Timeout.internalConnectMultipleTimeout (node:net:1707:5)
        at listOnTimeout (node:internal/timers:575:11)
        at process.processTimers (node:internal/timers:514:7) {
      errno: -101,
      code: 'ENETUNREACH',
      syscall: 'connect',
      address: '2600:1f18:2544:ce01:7707:2a5c:d55b:b060',
      port: 443
    },
    Error: connect ETIMEDOUT 34.207.27.105:443
        at createConnectionError (node:net:1643:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1702:38)
        at listOnTimeout (node:internal/timers:575:11)
        at process.processTimers (node:internal/timers:514:7) {
      errno: -110,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '34.207.27.105',
      port: 443
    },
    Error: connect ENETUNREACH 2600:1f18:2544:ce00:f4ec:1979:3f07:5ed3:443 - Local (:::0)
        at internalConnectMultiple (node:net:1180:16)
        at Timeout.internalConnectMultipleTimeout (node:net:1707:5)
        at listOnTimeout (node:internal/timers:575:11)
        at process.processTimers (node:internal/timers:514:7) {
      errno: -101,
      code: 'ENETUNREACH',
      syscall: 'connect',
      address: '2600:1f18:2544:ce00:f4ec:1979:3f07:5ed3',
      port: 443
    },
    Error: connect ETIMEDOUT 18.214.158.206:443
        at createConnectionError (node:net:1643:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1702:38)
        at listOnTimeout (node:internal/timers:575:11)
        at process.processTimers (node:internal/timers:514:7) {
      errno: -110,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '18.214.158.206',
      port: 443
    },
    Error: connect ENETUNREACH 2600:1f18:2544:ce05:b877:65fc:fb76:cfc7:443 - Local (:::0)
        at internalConnectMultiple (node:net:1180:16)
        at Timeout.internalConnectMultipleTimeout (node:net:1707:5)
        at listOnTimeout (node:internal/timers:575:11)
        at process.processTimers (node:internal/timers:514:7) {
      errno: -101,
      code: 'ENETUNREACH',
      syscall: 'connect',
      address: '2600:1f18:2544:ce05:b877:65fc:fb76:cfc7',
      port: 443
    }   ] }

Not sure what I am doing wrong here.

0

There are 0 best solutions below