protected void releaseAnyPublicIpForInstanceInRegion(String instanceId, String region) {
if (!autoAllocateElasticIps)
return;
try {
String ip = elasticIpCache.get(new RegionAndName(region, instanceId));
logger.debug(">> disassociating elastic IP %s", ip);
client.getElasticIPAddressApi().get().disassociateAddressInRegion(region, ip);
logger.trace("<< disassociated elastic IP %s", ip);
elasticIpCache.invalidate(new RegionAndName(region, instanceId));
logger.debug(">> releasing elastic IP %s", ip);
client.getElasticIPAddressApi().get().releaseAddressInRegion(region, ip);
logger.trace("<< released elastic IP %s", ip);
} catch (CacheLoader.InvalidCacheLoadException e) {
// no ip was found