我正在使用AWS Lambda在SSM中运行命令。这是代码:
const AWS = require('aws-sdk')
const ssm = new AWS.SSM()
exports.handler = (event, context, callback) => {
ssm.sendCommand({
DocumentName: "AWS-RunShellScript",
CloudWatchOutputConfig : {
CloudWatchOutputEnabled: true,
CloudWatchLogGroupName: "EC2CommandsFromLambda"
},
InstanceIds: [ "instace-id" ],
Parameters: {
"commands": [
"./start.sh"
],
"workingDirectory": [
"path"
]
},
TimeoutSeconds: 3600
}, function(err, data) {
if (err) {
console.log(err);
} else {
console.log(data);
callback(null, "Command Running Successfully");
}
})
};
我遇到以下错误:
UnexpectedParameter:在参数中找到意外的键“ CloudWatchOutputConfig” 在ParamValidator.fail(/var/runtime/node_modules/aws-sdk/lib/param_validator.js:50:37)
如何从Lambda启用云监视日志?因为根据sdk,参数“ CloudWatchOutputConfig”应该可以工作。
答案 0 :(得分:1)
我遇到了同样的问题,对我来说,解决方法是将我的aws-sdk
模块升级到最新版本,在撰写本文时为:2.403.0