mirror of https://github.com/apache/druid.git
fix public IP not working in EC2 autoscaling
This commit is contained in:
parent
20fdb627d9
commit
4ebdfea76f
|
@ -108,31 +108,40 @@ public class EC2AutoScaler implements AutoScaler<EC2EnvironmentConfig>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final RunInstancesResult result = amazonEC2Client.runInstances(
|
RunInstancesRequest request = new RunInstancesRequest(
|
||||||
new RunInstancesRequest(
|
|
||||||
workerConfig.getAmiId(),
|
workerConfig.getAmiId(),
|
||||||
workerConfig.getMinInstances(),
|
workerConfig.getMinInstances(),
|
||||||
workerConfig.getMaxInstances()
|
workerConfig.getMaxInstances()
|
||||||
)
|
)
|
||||||
.withInstanceType(workerConfig.getInstanceType())
|
.withInstanceType(workerConfig.getInstanceType())
|
||||||
.withSecurityGroupIds(workerConfig.getSecurityGroupIds())
|
|
||||||
.withPlacement(new Placement(envConfig.getAvailabilityZone()))
|
.withPlacement(new Placement(envConfig.getAvailabilityZone()))
|
||||||
.withKeyName(workerConfig.getKeyName())
|
.withKeyName(workerConfig.getKeyName())
|
||||||
.withSubnetId(workerConfig.getSubnetId())
|
|
||||||
.withIamInstanceProfile(
|
.withIamInstanceProfile(
|
||||||
workerConfig.getIamProfile() == null
|
workerConfig.getIamProfile() == null
|
||||||
? null
|
? null
|
||||||
: workerConfig.getIamProfile().toIamInstanceProfileSpecification()
|
: workerConfig.getIamProfile().toIamInstanceProfileSpecification()
|
||||||
)
|
)
|
||||||
.withNetworkInterfaces(
|
.withUserData(userDataBase64);
|
||||||
workerConfig.getAssociatePublicIpAddress() == null
|
|
||||||
? null
|
// InstanceNetworkInterfaceSpecification.getAssociatePublicIpAddress may be
|
||||||
: new InstanceNetworkInterfaceSpecification().withAssociatePublicIpAddress(
|
// true or false by default in EC2, depending on the subnet.
|
||||||
workerConfig.getAssociatePublicIpAddress()
|
// Setting EC2NodeData.getAssociatePublicIpAddress explicitly will use that value instead,
|
||||||
)
|
// leaving it null uses the EC2 default.
|
||||||
)
|
if (workerConfig.getAssociatePublicIpAddress() != null) {
|
||||||
.withUserData(userDataBase64)
|
request.withNetworkInterfaces(
|
||||||
|
new InstanceNetworkInterfaceSpecification()
|
||||||
|
.withAssociatePublicIpAddress(workerConfig.getAssociatePublicIpAddress())
|
||||||
|
.withSubnetId(workerConfig.getSubnetId())
|
||||||
|
.withGroups(workerConfig.getSecurityGroupIds())
|
||||||
|
.withDeviceIndex(0)
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
request
|
||||||
|
.withSecurityGroupIds(workerConfig.getSecurityGroupIds())
|
||||||
|
.withSubnetId(workerConfig.getSubnetId());
|
||||||
|
}
|
||||||
|
|
||||||
|
final RunInstancesResult result = amazonEC2Client.runInstances(request);
|
||||||
|
|
||||||
final List<String> instanceIds = Lists.transform(
|
final List<String> instanceIds = Lists.transform(
|
||||||
result.getReservation().getInstances(),
|
result.getReservation().getInstances(),
|
||||||
|
|
Loading…
Reference in New Issue