4

I am using AWS Lambda to Run Command in SSM. This is the code:

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");
    }
})
};

I am getting following error:

UnexpectedParameter: Unexpected key 'CloudWatchOutputConfig' found in params at ParamValidator.fail (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:50:37)

How do I enable cloud watch logs from Lambda? Because according to the sdk the param 'CloudWatchOutputConfig' should work.

swapp1990
  • 454
  • 1
  • 5
  • 16

1 Answers1

1

I had this same issue and for me the resolution was to upgrade my aws-sdk module to the latest version which at the time of writing is: 2.403.0

k00k
  • 17,314
  • 13
  • 59
  • 86