我不明白我的错误:
“配置中缺少凭据”
您可以在“实际结果”部分看到完整的错误
通常, 输出显示给我:
我尝试查找问题,有时我看到'AWS_SDK_LOAD',但不明白...
能帮我吗
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);
}
});
实际结果:
{ 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)'