builder/amazon-chroot: Fixes for amazon-chroot builder

These are needed for chroot builder to work
This commit is contained in:
Clint Shryock 2015-06-22 17:08:41 -05:00
parent 42000dda66
commit f374edc2b8
3 changed files with 15 additions and 6 deletions

View File

@ -29,7 +29,7 @@ func (s *StepCreateVolume) Run(state multistep.StateBag) multistep.StepAction {
log.Printf("Searching for root device of the image (%s)", *image.RootDeviceName)
var rootDevice *ec2.BlockDeviceMapping
for _, device := range image.BlockDeviceMappings {
if device.DeviceName == image.RootDeviceName {
if *device.DeviceName == *image.RootDeviceName {
rootDevice = device
break
}

View File

@ -49,7 +49,7 @@ func (s *StepInstanceInfo) Run(state multistep.StateBag) multistep.StepAction {
return multistep.ActionHalt
}
instance := &instancesResp.Reservations[0].Instances[0]
instance := instancesResp.Reservations[0].Instances[0]
state.Put("instance", instance)
return multistep.ActionContinue

View File

@ -24,14 +24,20 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
blockDevices := make([]*ec2.BlockDeviceMapping, len(image.BlockDeviceMappings))
for i, device := range image.BlockDeviceMappings {
newDevice := device
if newDevice.DeviceName == image.RootDeviceName {
if *newDevice.DeviceName == *image.RootDeviceName {
if newDevice.EBS != nil {
newDevice.EBS.SnapshotID = &snapshotId
newDevice.EBS.SnapshotID = aws.String(snapshotId)
} else {
newDevice.EBS = &ec2.EBSBlockDevice{SnapshotID: &snapshotId}
newDevice.EBS = &ec2.EBSBlockDevice{SnapshotID: aws.String(snapshotId)}
}
}
// assume working from a snapshot, so we unset the Encrypted field if set,
// otherwise AWS API will return InvalidParameter
if newDevice.EBS.Encrypted != nil {
newDevice.EBS.Encrypted = nil
}
blockDevices[i] = newDevice
}
@ -82,7 +88,10 @@ func buildRegisterOpts(config *Config, image *ec2.Image, blockDevices []*ec2.Blo
Architecture: image.Architecture,
RootDeviceName: image.RootDeviceName,
BlockDeviceMappings: blockDevices,
VirtualizationType: &config.AMIVirtType,
}
if config.AMIVirtType != "" {
registerOpts.VirtualizationType = aws.String(config.AMIVirtType)
}
if config.AMIVirtType != "hvm" {