我尝试通过Node.js AWS SDK执行实例创建,并且我使用以下代码:
OpsWorks.createInstanceAsync({
InstanceType: config.instanceType,
LayerIds: [config.layerId],
StackId: config.stackId,
RootDeviceType: params.RootDeviceType || 'ebs',
AvailabilityZone: params.AvailabilityZone,
InstanceType: params.InstanceType,
SubnetId: params.SubnetId,
AmiId: config.amiId
});
});
当没有指定AmiId时,这段代码工作正常(启动全新实例)。为了减少部署时间,我计划使用AMI,当添加AmiId参数时,我收到以下错误:
ValidationException: The AMI ID cannot be set for this OS
为什么会在OpsWorks上发生这种情况(Ubuntu 14.04)?
由于
答案 0 :(得分:1)
您需要为AMI添加操作系统。请使用以下代码。
OpsWorks.createInstanceAsync({
InstanceType: config.instanceType,
LayerIds: [config.layerId],
StackId: config.stackId,
RootDeviceType: params.RootDeviceType || 'ebs',
AvailabilityZone: params.AvailabilityZone,
InstanceType: params.InstanceType,
SubnetId: params.SubnetId,
Os: 'Custom',
AmiId: config.amiId
});
});