Commit f374edc2 authored by Clint Shryock's avatar Clint Shryock

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

These are needed for chroot builder to work
parent 42000dda
......@@ -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
}
......
......@@ -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
......
......@@ -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" {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment