List of usage examples for com.amazonaws.services.autoscaling.model AutoScalingGroup getTargetGroupARNs
public java.util.List<String> getTargetGroupARNs()
The Amazon Resource Names (ARN) of the target groups for your load balancer.
From source file:com.netflix.spinnaker.clouddriver.aws.event.DefaultAfterResizeEventHandler.java
License:Apache License
/** * There is an opportunity to expedite a resize to zero by explicitly terminating instances * (server group _must not_ be attached to a load balancer nor have any life cycle hooks) */// www . j av a2 s . c o m @Override public void handle(AfterResizeEvent event) { AutoScalingGroup autoScalingGroup = event.getAutoScalingGroup(); if (event.getCapacity() == null || event.getCapacity().getDesired() == null) { return; } if (event.getCapacity().getDesired() > 0) { return; } if (!autoScalingGroup.getLoadBalancerNames().isEmpty() || !autoScalingGroup.getTargetGroupARNs().isEmpty()) { event.getTask().updateStatus(PHASE, "Skipping explicit instance termination, server group is attached to one or more load balancers"); return; } try { List<LifecycleHook> existingLifecycleHooks = fetchTerminatingLifecycleHooks( event.getAmazonAutoScaling(), autoScalingGroup.getAutoScalingGroupName()); if (!existingLifecycleHooks.isEmpty()) { event.getTask().updateStatus(PHASE, "Skipping explicit instance termination, server group has one or more lifecycle hooks"); return; } } catch (Exception e) { log.error("Unable to fetch lifecycle hooks (serverGroupName: {}, arn: {})", autoScalingGroup.getAutoScalingGroupName(), autoScalingGroup.getAutoScalingGroupARN(), e); event.getTask().updateStatus(PHASE, String.format( "Skipping explicit instance termination, unable to fetch lifecycle hooks (reason: '%s')", e.getMessage())); return; } terminateInstancesInAutoScalingGroup(event.getTask(), event.getAmazonEC2(), event.getAutoScalingGroup()); }