Example usage for com.amazonaws.services.ec2.model ReleaseAddressRequest setAllocationId

List of usage examples for com.amazonaws.services.ec2.model ReleaseAddressRequest setAllocationId

Introduction

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

Prototype


public void setAllocationId(String allocationId) 

Source Link

Document

[EC2-VPC] The allocation ID.

Usage

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

License:Open Source License

public static void cleanupPublicIPs() {
    DescribeAddressesResult result = ec2.describeAddresses();
    List<Address> addresses = result.getAddresses();

    for (Address address : addresses) {

        ReleaseAddressRequest releaseReq = new ReleaseAddressRequest();
        releaseReq.setAllocationId(address.getAllocationId());
        releaseReq.setPublicIp(address.getPublicIp());

        if (address.getInstanceId() == null || address.getInstanceId().equals("")) {
            ec2.releaseAddress(releaseReq);
        }/*  www.j  a v  a  2 s . c  o  m*/
    }
}