[英]Get the next (Private) Ip address from the Amazon AWS SDK for an EC2 instance
I've been playing with the amazon AWS SDK (for NodeJS) for the last couple of days, especially with the EC2 part. 最近几天,我一直在使用Amazon AWS SDK(用于NodeJS),尤其是EC2部分。 I was wondering if it is possible to know what your IP-address will be before booting new instances.
我想知道是否可以在启动新实例之前知道您的IP地址。
I checked the documentation and google but I couldn't find an answer to this. 我检查了文档和Google,但找不到答案。 So before I run the
runInstances
function I have a function that returns me the next n
ip-address that will be assigned to me if I create n
new instances right now. 所以,在我运行
runInstances
功能我有返回我的下一个函数n
如果我创建将分配给我的IP地址n
现在新的实例。
I don't know if this is possible but I can't find anything about this. 我不知道这是否可行,但是我找不到任何东西。
You cannot predict the private IP address that will be assigned, but you can specify the IP address when the instance is launched. 您无法预测将要分配的专用IP地址,但是可以在启动实例时指定 IP地址。
The runInstances()
command in the Amazon SDK for node.js has a PrivateIpAddress
parameter that can specify the IP address to assign to the instance: Amazon SDK的node.js的
runInstances()
命令具有PrivateIpAddress
参数,该参数可以指定要分配给实例的IP地址:
var params = {
ImageId: 'STRING_VALUE', /* required */
MaxCount: 0, /* required */
MinCount: 0, /* required */
NetworkInterfaces: [
{
PrivateIpAddress: 'STRING_VALUE'
}
/* etc */
};
ec2.runInstances(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.