使用AWS SDK启动ec2实例时指定存储(Specify storage when launching ec2 instance with AWS SDK)
在文档中找不到如何在启动新的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); });
In could not find in the docs how to specify the root storage when starting a new ec2 instance. If I start an instance through the web interface, I can go through this step:
to change storage settings before launching the instance. How can I do that with the SDK? Currently I have:
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); });
原文:https://stackoverflow.com/questions/39985698
更新时间:2022-11-07 07:11