我正在尝试使用lambda函数来确定弹性beantalk环境的运行状况。但是,该API当前无法正常工作。
如何复制:
添加新的lambda nodejs 8.10应用。
'use strict'
var AWS = require('aws-sdk');
var elasticbeanstalk = new AWS.ElasticBeanstalk();
exports.handler = (event, context, callback) => {
var fromEnvironment = 'envname';
var params = {
EnvironmentNames: [fromEnvironment]
};
elasticbeanstalk.describeEnvironments(params, function (err, envData) {
if (err) console.log(err, err.stack); // an error occurred
else {
console.log("Found ",envData.Environments.map(x=>x.EnvironmentId),envData.Environments.map(x=>x.Health))
var paramsHealth = {
AttributeNames: [
"All"
],
EnvironmentName: fromEnvironment
};
elasticbeanstalk.describeEnvironmentHealth(paramsHealth, function (err, health) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(health); // successful response
});
}
});
};
结果:
Function Logs:
START RequestId: 4be2ff8b-90dd-11e8-af92-1b0ba673de5e Version: $LATEST
2018-07-26T14:07:58.644Z 4be2ff8b-90dd-11e8-af92-1b0ba673de5e Found [ 'e-fe12312312' ] [ 'Green' ]
2018-07-26T14:07:58.868Z 4be2ff8b-90dd-11e8-af92-1b0ba673de5e { InvalidRequestException: DescribeEnvironmentHealth is not supported.
at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/query.js:47:29)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683: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:685:12)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:115:18)