com.elastisys.scale.cloudpool.aws.commons.requests.autoscaling.AttachAutoScalingGroupInstance Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cloudpool.aws.commons Show documentation
Show all versions of cloudpool.aws.commons Show documentation
Common utility classes for building Amazon AWS-based cloud pools.
The newest version!
package com.elastisys.scale.cloudpool.aws.commons.requests.autoscaling;
import java.util.concurrent.Callable;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.services.autoscaling.model.AttachInstancesRequest;
/**
* A {@link Callable} task that, when executed, requests a particular instance
* to be attached to an Auto Scaling Group. As a side-effect, the desired
* capacity of the Auto Scaling Group is incremented.
*/
public class AttachAutoScalingGroupInstance extends AmazonAutoScalingRequest {
/** The name of the Auto Scaling Group. */
private final String autoScalingGroup;
/** The machine instance identifier to be attached. */
private final String instanceId;
public AttachAutoScalingGroupInstance(AWSCredentials awsCredentials, String region,
ClientConfiguration clientConfig, String autoScalingGroup, String instanceId) {
super(awsCredentials, region, clientConfig);
this.autoScalingGroup = autoScalingGroup;
this.instanceId = instanceId;
}
@Override
public Void call() {
AttachInstancesRequest request = new AttachInstancesRequest().withAutoScalingGroupName(this.autoScalingGroup)
.withInstanceIds(this.instanceId);
getClient().getApi().attachInstances(request);
return null;
}
}