Example usage for com.amazonaws.services.autoscaling.model AutoScalingInstanceDetails getProtectedFromScaleIn

List of usage examples for com.amazonaws.services.autoscaling.model AutoScalingInstanceDetails getProtectedFromScaleIn

Introduction

In this page you can find the example usage for com.amazonaws.services.autoscaling.model AutoScalingInstanceDetails getProtectedFromScaleIn.

Prototype


public Boolean getProtectedFromScaleIn() 

Source Link

Document

Indicates whether the instance is protected from termination by Amazon EC2 Auto Scaling when scaling in.

Usage

From source file:com.pinterest.arcee.autoscaling.AwsAutoScalingManager.java

License:Apache License

@Override
public boolean isInstanceProtected(String instance) throws Exception {
    DescribeAutoScalingInstancesRequest request = new DescribeAutoScalingInstancesRequest();
    request.setInstanceIds(Collections.singletonList(instance));
    DescribeAutoScalingInstancesResult result = aasClient.describeAutoScalingInstances(request);
    if (result.getAutoScalingInstances().isEmpty()) {
        LOG.error(String.format("Failed to find any instances details for  %s", instance));
        return false;
    }//ww w .  j  a  v  a2  s.co  m
    AutoScalingInstanceDetails details = result.getAutoScalingInstances().get(0);
    return details.getProtectedFromScaleIn();
}