1

I don't understand my error:

"Missing credentials in config"

You can see full error to the part 'Actual result'

Normally, The output show me :

  • timestamp
  • Average
  • Unit

I try to find the problem, sometimes i see 'AWS_SDK_LOAD' but don't understand...

Can you help me please

var AWS = require('aws-sdk');

    AWS.config.region = 'eu-west-1';
    var cw = new AWS.CloudWatch({apiVersion: '2010-08-01'});
    var startDate = new Date();
    var endDate = new Date();

    startDate.setHours(startDate.getHours()-1);

    var params = {  
     StartTime: startDate,
      EndTime: endDate,
      Namespace: 'Lambda-Ping/HTTP', /* required */
      Period: 300, /* required */
       MetricName: 'StatusCode', /* required */
       Dimensions: [            
        {   
          Name: 'Endpoint', /* required */
          Value: 'https://****'
        },
        /* more items */
      ], 
      Statistics: [
        'Average'
        /* more items */
      ],
    };

        cw.getMetricStatistics(params, function(err, data) {
            if (err){
                    console.log(err, err.stack); // an error occurred
            } else {                                            
                console.log(data);
            }
          });

Actual result:

{ Error: connect ENETUNREACH 169.254.169.254:80
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1117:14)
  message: 'Missing credentials in config',
  errno: 'ENETUNREACH',
  code: 'CredentialsError',
  syscall: 'connect',
  address: '169.254.169.254',
  port: 80,
  time: 2019-01-22T15:33:36.619Z,
  originalError:
   { message: 'Could not load credentials from any providers',
     errno: 'ENETUNREACH',
     code: 'CredentialsError',
     syscall: 'connect',
     address: '169.254.169.254',
     port: 80,
     time: 2019-01-22T15:33:36.619Z,
     originalError:
      { errno: 'ENETUNREACH',
        code: 'ENETUNREACH',
        syscall: 'connect',
        address: '169.254.169.254',
        port: 80,
        message: 'connect ENETUNREACH 169.254.169.254:80' } } } 'Error: connect ENETUNREACH 169.254.169.254:80\n    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1117:14)'
John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • See https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html. Make sure that one of the available means of supplying credentials to the SDK is actually in place. Preferably IAM roles if running within AWS. – jarmod Jan 22 '19 at 16:02
  • Ok .. When i'm using Linux on VirtualBox, it works But kno, i try to work with windows, and this error it display ... – marcilles Stanislas Jan 22 '19 at 16:32
  • 1
    You need to supply credentials for each environment in a way that's supported for that environment. If you're supplying them for Linux/VirtualBox in ~/.aws/credentials for example, then you might choose to supply them in %USERPROFILE%\.aws\credentials on Windows. Or via environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, if you prefer. – jarmod Jan 22 '19 at 16:38

0 Answers0