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 { ...@@ -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) log.Printf("Searching for root device of the image (%s)", *image.RootDeviceName)
var rootDevice *ec2.BlockDeviceMapping var rootDevice *ec2.BlockDeviceMapping
for _, device := range image.BlockDeviceMappings { for _, device := range image.BlockDeviceMappings {
if device.DeviceName == image.RootDeviceName { if *device.DeviceName == *image.RootDeviceName {
rootDevice = device rootDevice = device
break break
} }
......
...@@ -49,7 +49,7 @@ func (s *StepInstanceInfo) Run(state multistep.StateBag) multistep.StepAction { ...@@ -49,7 +49,7 @@ func (s *StepInstanceInfo) Run(state multistep.StateBag) multistep.StepAction {
return multistep.ActionHalt return multistep.ActionHalt
} }
instance := &instancesResp.Reservations[0].Instances[0] instance := instancesResp.Reservations[0].Instances[0]
state.Put("instance", instance) state.Put("instance", instance)
return multistep.ActionContinue return multistep.ActionContinue
......
...@@ -24,14 +24,20 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction { ...@@ -24,14 +24,20 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
blockDevices := make([]*ec2.BlockDeviceMapping, len(image.BlockDeviceMappings)) blockDevices := make([]*ec2.BlockDeviceMapping, len(image.BlockDeviceMappings))
for i, device := range image.BlockDeviceMappings { for i, device := range image.BlockDeviceMappings {
newDevice := device newDevice := device
if newDevice.DeviceName == image.RootDeviceName { if *newDevice.DeviceName == *image.RootDeviceName {
if newDevice.EBS != nil { if newDevice.EBS != nil {
newDevice.EBS.SnapshotID = &snapshotId newDevice.EBS.SnapshotID = aws.String(snapshotId)
} else { } 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 blockDevices[i] = newDevice
} }
...@@ -82,7 +88,10 @@ func buildRegisterOpts(config *Config, image *ec2.Image, blockDevices []*ec2.Blo ...@@ -82,7 +88,10 @@ func buildRegisterOpts(config *Config, image *ec2.Image, blockDevices []*ec2.Blo
Architecture: image.Architecture, Architecture: image.Architecture,
RootDeviceName: image.RootDeviceName, RootDeviceName: image.RootDeviceName,
BlockDeviceMappings: blockDevices, BlockDeviceMappings: blockDevices,
VirtualizationType: &config.AMIVirtType, }
if config.AMIVirtType != "" {
registerOpts.VirtualizationType = aws.String(config.AMIVirtType)
} }
if config.AMIVirtType != "hvm" { 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