[英]EC2 - Create Instance params for javascript aws sdk
var params = {
ImageId: 'ami-23ebb513',
InstanceType: 't1.micro',
MinCount:1, MaxCount: 1
}; };
ec2.runInstances(params, function(err, data) {
})
This code is good to start with launch instances. 这段代码从启动实例开始很好。 But i am trying to customize the instance's security group, public key for ssh etc. How can we configure these params?
但是我正在尝试自定义实例的安全组,ssh的公钥等。我们如何配置这些参数? I see not much docs is available that lists out the params supported by
aws-sdk
. 我看到没有多少文档可以列出
aws-sdk
支持的参数。
You should be able to get most of what you want with params. 您应该能够使用params获得大部分想要的东西。
Params additions would be: 参数添加为:
NetworkInterfaces: [{DeviceIndex:0, SubnetId: 'subnet-12345', AssociatePublicIpAddress:true, Groups: ['sg-12345']}],
KeyName: 'MyKey'
The only thing you can't really get with the ec2-runInstances is tag creation. ec2-runInstances唯一无法真正获得的是标记创建。 That would come from a second api call within the first function, like so:
这将来自第一个函数中的第二个api调用,如下所示:
params = {Resources: [data['instanceId']], Tags: [
{Key: 'Name', Value: 'SomeName-' + data['instanceId']},
{Key: 'Project', Value: 'My Project'},
{Key: 'SubProject', Value: 'SpotInstanceAuto'},
{Key: 'Creator', Value: 'Jason Nichols'},
...
]};
ec2.createTags(params, function(err) {
console.log("Tagging instance", err ? "failure" : "success");
...
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.