在docs中找不到如何在启动新的ec2实例时指定根存储。如果我通过Web界面启动实例,我可以执行此步骤:
在启动实例之前更改存储设置。我怎么能用SDK做到这一点?目前我有:
AWS = require('aws-sdk');
var ec2 = new AWS.EC2({
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey,
region: 'us-east-1'
});
var params = {
ImageId: 'ami-123456',
InstanceType: 't2.micro',
MinCount: 1, MaxCount: 1,
SecurityGroups: [
'my-security-group',
],
// how to specify storage settings??
};
// Create the instance
ec2.runInstances(params, function(err, data) {
if (err) { console.log("Could not create instance", err); return; }
var instanceId = data.Instances[0].InstanceId;
console.log("Created instance", instanceId);
});
答案 0 :(得分:1)
BlockDeviceMappings:[{
DeviceName:'/dev/sda1',
Ebs:{
VolumeSize:8,
DeleteOnTermination:true,
VolumeType:"gp2",
}
}]