Skip to content

Commit

Permalink
Update AwsUtil.java
Browse files Browse the repository at this point in the history
From pull request
Netflix#102
  • Loading branch information
vermapratyush authored Jan 6, 2017
1 parent 3530bba commit f2c83bf
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,20 @@ public class AwsUtil {
private final AmazonEC2Client ec2Client;

public AwsUtil() {
asgClient = new AmazonAutoScalingClient();
ec2Client = new AmazonEC2Client();

String endpoint = "autoscaling." + DynamicPropertyFactory.getInstance().getStringProperty("turbine.region", "us-east-1").get() + ".amazonaws.com";
asgClient.setEndpoint(endpoint);
logger.debug("Set the asgClient endpoint to [{}]", endpoint);
String region = DynamicPropertyFactory.getInstance().getStringProperty("turbine.region", "us-east-1").get();
String ec2Endpoint = "ec2." + region + ".amazonaws.com";

ec2Client = new AmazonEC2Client();
ec2Client.setEndpoint(ec2Endpoint);

logger.debug("Set the ec2Client ec2Endpoint to [{}]", ec2Endpoint);

String asgEndpoint = "autoscaling." + region + ".amazonaws.com";

asgClient = new AmazonAutoScalingClient();
asgClient.setEndpoint(asgEndpoint);

logger.debug("Set the asgClient asgEndpoint to [{}]", asgEndpoint);
}

/**
Expand Down Expand Up @@ -112,10 +120,10 @@ public String apply(com.amazonaws.services.autoscaling.model.Instance asgInstanc

String statusName = ec2Instance.getState().getName();
boolean status = statusName.equals("running"); // see com.amazonaws.services.ec2.model.InstanceState for values

Instance turbineInstance = new Instance(hostname, asgName, status);
turbineInstance.getAttributes().put("asg", asgName);

turbineInstances.add(turbineInstance);
}
}
Expand Down

0 comments on commit f2c83bf

Please sign in to comment.