List of usage examples for com.amazonaws.services.ec2.model AssociateAddressResult getAssociationId
public String getAssociationId()
[EC2-VPC] The ID that represents the association of the Elastic IP address with an instance.
From source file:aws.example.ec2.AllocateAddress.java
License:Open Source License
public static void main(String[] args) { final String USAGE = "To run this example, supply an instance id\n" + "Ex: AllocateAddress <instance_id>\n"; if (args.length != 1) { System.out.println(USAGE); System.exit(1);// w w w . j a va 2s. c o m } String instance_id = args[0]; final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); AllocateAddressRequest allocate_request = new AllocateAddressRequest().withDomain(DomainType.Vpc); AllocateAddressResult allocate_response = ec2.allocateAddress(allocate_request); String allocation_id = allocate_response.getAllocationId(); AssociateAddressRequest associate_request = new AssociateAddressRequest().withInstanceId(instance_id) .withAllocationId(allocation_id); AssociateAddressResult associate_response = ec2.associateAddress(associate_request); System.out.printf("Successfully associated Elastic IP address %s " + "with instance %s", associate_response.getAssociationId(), instance_id); }
From source file:ec2.AllocateAddress.java
License:Open Source License
public static void main(String[] args) { final String USAGE = "To run this example, supply an instance id\n" + "Ex: AllocateAddress <instance-id>\n"; if (args.length != 1) { System.out.println(USAGE); System.exit(1);//from ww w. ja v a 2 s. co m } String instanceId = args[0]; final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); AllocateAddressRequest allocateAddressRequest = new AllocateAddressRequest().withDomain(DomainType.Vpc); AllocateAddressResult allocateAddressResponsee = ec2.allocateAddress(allocateAddressRequest); String allocationId = allocateAddressResponsee.getAllocationId(); AssociateAddressRequest request = new AssociateAddressRequest().withInstanceId(instanceId) .withAllocationId(allocationId); AssociateAddressResult response = ec2.associateAddress(request); System.out.printf("Successfully associated elastic ip address %s with instance %s", response.getAssociationId(), instanceId); }