1

When using Apache JClouds, how do you get launch a compute instance with a public IP? This is different from an elastic IP. Using the official AWS API you can do something like:

//create network information
InstanceNetworkInterfaceSpecification networkWithPublicIp = new InstanceNetworkInterfaceSpecification()
            .withSubnetId(subnetId)
            .withAssociatePublicIpAddress(true)
            .withGroups( securityGroupIds )
            .withDeviceIndex(0);

Once the node is launched, it will have a randomly assigned public IP (not elastic). Is there a way to do this with Jclouds and AWSEC2TemplateOptions?

YoungDinosaur
  • 1,550
  • 17
  • 22
  • I find that sometimes jClouds creates ec2 instances that don't have a public IP. Did you find a solution? – JRun Feb 04 '21 at 11:58

1 Answers1

-1

There is an example in the doc at http://jclouds.apache.org/guides/aws/

// 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
    Hmm, it appears that logic is to assocate an elastic IP with the address. With the official API you don’t need to use expensive elastic IPs. You can just tell it to have a randomly assigned public IP. – YoungDinosaur Aug 24 '18 at 02:19
  • Not sure I understand. Elastic IPs are free, as long as they are being used by an instance. Amazon will charge you $0.01/hr for each EIP that you reserve and do not use. – Andrea Turli Aug 24 '18 at 11:51
  • The point is that sometimes, jClouds creates EC2 instances that don't have a random public IP. Why, how to prevent, and what to do in case it happens. Using ElasticIP means you need to take care of dis-associating and deleting the EIP when done – JRun Feb 04 '21 at 11:57