简体   繁体   English

从Amazon AWS开发工具包获取EC2实例的下一个(私有)IP地址

[英]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.

相关问题 ip.address()在aws上不起作用。 如何以编程方式获取AWS EC2的IP地址? - ip.address() does not work on aws. How to get the IP address of AWS EC2 programmatically? EC2 实例更改了公共 IP 地址。 我可以重新找回旧的 IP 地址吗? - EC2 instance changed public IP address. Can I get the old IP address back again? 无法访问 AWS EC2 实例 IP - Not able to access AWS EC2 instance IP 如何使用 aws-sdk Javascript 获取 EC2 public ip - How to get EC2 public ip using aws-sdk Javascript 我的EC2实例中的IP地址解析错误吗? - Is the IP address resolution wrong in my EC2 instance? 我的客户端不在 aws(amazon) Ec2 实例上工作 - My client side is not working on aws(amazon) Ec2 Instance 从服务器请求资源时是否可以隐藏aws ec2实例的ip? - Is it possible to hide ip of aws ec2 instance while requesting resources from server? 无法使用 AWS EC2 实例上的端口 25 从 nodejs nodemailer 发送 gmail 地址的邮件 - Cannot send mails for gmail address from nodejs nodemailer using port 25 on AWS EC2 instance 如何使用 node.js AWS 开发工具包从启动模板创建 EC2 实例 - How can you create an EC2 Instance from a launch template with the node.js AWS SDK 如何在AWS EC2(Linux实例)上部署Next js - How to deploy Next js on aws ec2 (linux instance)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM