2

Using the aws cli, it works perfectly:

aws ec2 run-instances --launch-template LaunchTemplateName=mytempname,Version=24

Using the aws sdk:

var params = {
  LaunchTemplate: {
    LaunchTemplateName: 'mytempname',
    Version: '24'
  }
};

ec2.runInstances(params, function (err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
})

I get lots of errors asking me to add more params such as MaxCount, MinCount, region, but these are already defined in the template.

{ MultipleValidationErrors: There were 2 validation errors:
* MissingRequiredParameter: Missing required key 'MaxCount' in params
* MissingRequiredParameter: Missing required key 'MinCount' in params
{ ConfigError: Missing region in config

Should I fetch the launch template first to be able to build the correct runInstances? But in that case, why is it working properly using the cli?

Alexis
  • 2,136
  • 2
  • 19
  • 47
  • I went through the official documentation and these params are not part of the launchTemplate, the aws cli has default options like MaxCount 1, MinCount 1, I assume it us your default region. I think that's why it worked. I would extend the `params` object with the required properties. – Sándor Bakos Aug 09 '19 at 09:42
  • I haven't thought about the default values I defined during `aws configure`, indeed... I will then extend the params with these mandatory parameters. Thanks! – Alexis Aug 09 '19 at 10:54

0 Answers0