Example usage for com.amazonaws.services.ec2.model AssociateAddressRequest setInstanceId

List of usage examples for com.amazonaws.services.ec2.model AssociateAddressRequest setInstanceId

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model AssociateAddressRequest setInstanceId.

Prototype


public void setInstanceId(String instanceId) 

Source Link

Document

The ID of the instance.

Usage

From source file:virtualIT.java

License:Open Source License

private void elasticIP(String createdInstanceId) {

    /* START Elastic IP Address */

    AllocateAddressResult elasticResult = ec2.allocateAddress();
    String elasticIp = elasticResult.getPublicIp();
    System.out.println("New elastic IP: " + elasticIp);

    //associate/*  w ww .  java  2s .  com*/
    AssociateAddressRequest aar = new AssociateAddressRequest();
    aar.setInstanceId(createdInstanceId);
    aar.setPublicIp(elasticIp);
    ec2.associateAddress(aar);

    /* END Elastic IP Address */
}

From source file:com.hpcloud.daas.ec2.AwsConsoleApp.java

License:Open Source License

public static String assignPublicIp(String instanceId) {
    AllocateAddressResult result = ec2.allocateAddress();

    AssociateAddressRequest assRequest = new AssociateAddressRequest();
    assRequest.setAllocationId(result.getAllocationId());
    assRequest.setPublicIp(result.getPublicIp());
    assRequest.setInstanceId(instanceId);

    AssociateAddressResult resp = ec2.associateAddress(assRequest);
    System.out.println(resp);//from  www  . j ava2  s .c  o  m

    return (result.getPublicIp());
}

From source file:com.liferay.amazontools.AsgardAMIDeployer.java

License:Open Source License

protected void associateElasticIpAddresses(List<String> instanceIds) {
    if (!properties.containsKey("elastic.ip.addresses")) {
        return;//from   w ww  .  j av  a  2  s.  c om
    }

    String elasticIpAddressesString = properties.getProperty("elastic.ip.addresses");

    String[] elasticIpAddresses = elasticIpAddressesString.split(",");

    for (int i = 0; (i < elasticIpAddresses.length) && (i < instanceIds.size()); i++) {

        System.out.println(
                "Associating IP address " + elasticIpAddresses[i] + " with instance " + instanceIds.get(i));

        AssociateAddressRequest associateAddressRequest = new AssociateAddressRequest();

        associateAddressRequest.setInstanceId(instanceIds.get(i));
        associateAddressRequest.setPublicIp(elasticIpAddresses[i]);

        amazonEC2Client.associateAddress(associateAddressRequest);
    }
}