|
|
|
|
@ -41,12 +41,32 @@ type StepRunSpotInstance struct {
|
|
|
|
|
UserData string
|
|
|
|
|
UserDataFile string
|
|
|
|
|
Ctx interpolate.Context
|
|
|
|
|
NoEphemeral bool
|
|
|
|
|
|
|
|
|
|
instanceId string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *StepRunSpotInstance) CreateTemplateData(userData *string, az string,
|
|
|
|
|
state multistep.StateBag, marketOptions *ec2.LaunchTemplateInstanceMarketOptionsRequest) *ec2.RequestLaunchTemplateData {
|
|
|
|
|
blockDeviceMappings := s.LaunchMappings.BuildEC2BlockDeviceMappings()
|
|
|
|
|
if s.NoEphemeral {
|
|
|
|
|
// This is only relevant for windows guests. Ephemeral drives by
|
|
|
|
|
// default are assigned to drive names xvdca-xvdcz.
|
|
|
|
|
// When vms are launched from the AWS console, they're automatically
|
|
|
|
|
// removed from the block devices if the user hasn't said to use them,
|
|
|
|
|
// but the SDK does not perform this cleanup. The following code just
|
|
|
|
|
// manually removes the ephemeral drives from the mapping so that they
|
|
|
|
|
// don't clutter up console views and cause confusion.
|
|
|
|
|
log.Printf("no_ephemeral was set, so creating drives xvdca-xvdcz as empty mappings")
|
|
|
|
|
DefaultEphemeralDeviceLetters := "abcdefghijklmnopqrstuvwxyz"
|
|
|
|
|
for _, letter := range DefaultEphemeralDeviceLetters {
|
|
|
|
|
bd := &ec2.BlockDeviceMapping{
|
|
|
|
|
DeviceName: aws.String("xvdc" + string(letter)),
|
|
|
|
|
NoDevice: aws.String(""),
|
|
|
|
|
}
|
|
|
|
|
blockDeviceMappings = append(blockDeviceMappings, bd)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Convert the BlockDeviceMapping into a
|
|
|
|
|
// LaunchTemplateBlockDeviceMappingRequest. These structs are identical,
|
|
|
|
|
// except for the EBS field -- on one, that field contains a
|
|
|
|
|
@ -55,7 +75,6 @@ func (s *StepRunSpotInstance) CreateTemplateData(userData *string, az string,
|
|
|
|
|
// LaunchTemplateEbsBlockDeviceRequest structs are themselves
|
|
|
|
|
// identical except for the struct's name, so you can cast one directly
|
|
|
|
|
// into the other.
|
|
|
|
|
blockDeviceMappings := s.LaunchMappings.BuildEC2BlockDeviceMappings()
|
|
|
|
|
var launchMappingRequests []*ec2.LaunchTemplateBlockDeviceMappingRequest
|
|
|
|
|
for _, mapping := range blockDeviceMappings {
|
|
|
|
|
launchRequest := &ec2.LaunchTemplateBlockDeviceMappingRequest{
|
|
|
|
|
|