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?