List of usage examples for com.amazonaws.services.ec2 AmazonEC2 releaseAddress
ReleaseAddressResult releaseAddress(ReleaseAddressRequest releaseAddressRequest);
Releases the specified Elastic IP address.
From source file:aws.example.ec2.ReleaseAddress.java
License:Open Source License
public static void main(String[] args) { final String USAGE = "To run this example, supply an allocation ID.\n" + "Ex: ReleaseAddress <allocation_id>\n"; if (args.length != 1) { System.out.println(USAGE); System.exit(1);/*www . j a v a2s . c o m*/ } String alloc_id = args[0]; final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); ReleaseAddressRequest request = new ReleaseAddressRequest().withAllocationId(alloc_id); ReleaseAddressResult response = ec2.releaseAddress(request); System.out.printf("Successfully released elastic IP address %s", alloc_id); }
From source file:com.urbancode.terraform.tasks.aws.helpers.AWSHelper.java
License:Apache License
/** * Releases an elastic IP with the given allocation id. * * @param allocationId//w w w. j ava 2s. c om * @param ec2Client */ public void releaseElasticIp(String allocationId, AmazonEC2 ec2Client) { ReleaseAddressRequest request = new ReleaseAddressRequest().withAllocationId(allocationId); ec2Client.releaseAddress(request); log.info("Elastic IP with allocation ID = " + allocationId + " released."); }
From source file:com.urbancode.terraform.tasks.aws.helpers.AWSHelper.java
License:Apache License
/** * Cleans up any elastic ips that are not associated with anything (via associationId). * The addresses are released.//www .j ava2s . c o m * * @param ec2Client */ public void cleanupElasticIps(AmazonEC2 ec2Client) { DescribeAddressesResult result = ec2Client.describeAddresses(); List<Address> addresses = result.getAddresses(); if (addresses != null) { for (Address address : addresses) { if (address.getAssociationId() != null && !address.getAssociationId().equals("")) { ReleaseAddressRequest request = new ReleaseAddressRequest() .withAllocationId(address.getAllocationId()); ec2Client.releaseAddress(request); } } } }
From source file:ec2.ReleaseAddress.java
License:Open Source License
public static void main(String[] args) { final String USAGE = "To run this example, supply an allocation id\n" + "Ex: ReleaseAddress <allocation-id>\n"; if (args.length != 1) { System.out.println(USAGE); System.exit(1);// www .j ava 2 s. c o m } String allocationId = args[0]; final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); ReleaseAddressRequest request = new ReleaseAddressRequest().withAllocationId(allocationId); ReleaseAddressResult response = ec2.releaseAddress(request); System.out.printf("Successfully released elastic IP address %s", allocationId); }