launchSpecification.setSecurityGroups(securityGroups);
// If a placement group has been set, then we will use it in the request.
if (placementGroupName != null && !placementGroupName.equals("")) {
// Setup the placement group to use with whatever name you desire.
SpotPlacement placement = new SpotPlacement();
placement.setGroupName(placementGroupName);
launchSpecification.setPlacement(placement);
}
// Check to see if we need to set the availability zone name.
if (availabilityZoneName != null && !availabilityZoneName.equals("")) {
// Setup the availability zone to use. Note we could retrieve the availability
// zones using the ec2.describeAvailabilityZones() API.
SpotPlacement placement = new SpotPlacement(availabilityZoneName);
launchSpecification.setPlacement(placement);
}
if (availabilityZoneGroupName != null && !availabilityZoneGroupName.equals("")) {
// Set the availability zone group.