public void unbind() throws Exception {
        InstanceInfo myInfo = applicationInfoManager.getInfo();
        String myInstanceId = ((AmazonInfo) myInfo.getDataCenterInfo()).get(AmazonInfo.MetaDataKey.instanceId);

        AmazonEC2 ec2 = getEC2Service();

        List<InstanceNetworkInterface> result = instanceData(myInstanceId, ec2).getNetworkInterfaces();

        List<String> ips = getCandidateIps();

        for(InstanceNetworkInterface networkInterface: result){
            if (ips.contains(networkInterface.getPrivateIpAddress())) {
                String attachmentId = networkInterface.getAttachment().getAttachmentId();
                ec2.detachNetworkInterface(new DetachNetworkInterfaceRequest().withAttachmentId(attachmentId));
                break;
            }
        }
    }
public void unbind ( ) throws Exception { InstanceInfo myInfo = applicationInfoManager . getInfo ( ) ; String myInstanceId = ( ( AmazonInfo ) myInfo . getDataCenterInfo ( ) ) . get ( AmazonInfo . MetaDataKey . instanceId ) ; AmazonEC2 ec2 = getEC2Service ( ) ; List < InstanceNetworkInterface > result = instanceData ( myInstanceId , ec2 ) . getNetworkInterfaces ( ) ; List < String > ips = getCandidateIps ( ) ; for ( InstanceNetworkInterface networkInterface : result ) { if ( ips . contains ( networkInterface . getPrivateIpAddress ( ) ) ) { String attachmentId = networkInterface . getAttachment ( ) . getAttachmentId ( ) ; ec2 . detachNetworkInterface ( new DetachNetworkInterfaceRequest ( ) . withAttachmentId ( attachmentId ) ) ; break ; } } }
Unbind the IP that this instance is associated with.