首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JClouds:如何申请AWS-EC2公共IP地址

JClouds:如何申请AWS-EC2公共IP地址
EN

Stack Overflow用户
提问于 2018-08-22 06:01:27
回答 1查看 32关注 0票数 1

使用Apache JClouds时,如何启动有公网IP的计算实例?这不同于弹性IP。使用官方AWS API,您可以执行以下操作:

代码语言:javascript
复制
//create network information
InstanceNetworkInterfaceSpecification networkWithPublicIp = new InstanceNetworkInterfaceSpecification()
            .withSubnetId(subnetId)
            .withAssociatePublicIpAddress(true)
            .withGroups( securityGroupIds )
            .withDeviceIndex(0);

节点启动后,会有一个随机分配的公网IP (非弹性)。有没有办法用Jcloud和AWSEC2TemplateOptions做到这一点?

EN

回答 1

Stack Overflow用户

发布于 2018-08-24 05:05:49

http://jclouds.apache.org/guides/aws/的文档中有一个示例

代码语言:javascript
复制
// ex. to get an ip and associate it with a node
String ip = ec2Client.getElasticIPAddressServices().allocateAddressInRegion(node.getLocation().getId());
ec2Client.getElasticIPAddressServices().associateAddressInRegion(node.getLocation().getId(),ip, node.getProviderId());
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51957284

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档