builder/amazon-ebssurrogate: Exclude duplicate root volume
This commit removes the root volume from the list of launch block device mappings passed to the image, since it is already passed in the form of a snapshot (which is then configured to be the root device). Without this commit, AMIs created using this builder have two root volumes attached on launch.
This commit is contained in:
parent
cc6abb0fc7
commit
1eec5bf058
|
@ -24,15 +24,23 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction {
|
||||||
|
|
||||||
ui.Say("Registering the AMI...")
|
ui.Say("Registering the AMI...")
|
||||||
|
|
||||||
blockDevices := s.BlockDevices
|
blockDevicesExcludingRoot := make([]*ec2.BlockDeviceMapping, 0, len(s.BlockDevices)-1)
|
||||||
blockDevices = append(blockDevices, s.RootDevice.createBlockDeviceMapping(snapshotId))
|
for _, blockDevice := range s.BlockDevices {
|
||||||
|
if *blockDevice.DeviceName == s.RootDevice.SourceDeviceName {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
blockDevicesExcludingRoot = append(blockDevicesExcludingRoot, blockDevice)
|
||||||
|
}
|
||||||
|
|
||||||
|
blockDevicesExcludingRoot = append(blockDevicesExcludingRoot, s.RootDevice.createBlockDeviceMapping(snapshotId))
|
||||||
|
|
||||||
registerOpts := &ec2.RegisterImageInput{
|
registerOpts := &ec2.RegisterImageInput{
|
||||||
Name: &config.AMIName,
|
Name: &config.AMIName,
|
||||||
Architecture: aws.String(ec2.ArchitectureValuesX8664),
|
Architecture: aws.String(ec2.ArchitectureValuesX8664),
|
||||||
RootDeviceName: aws.String(s.RootDevice.DeviceName),
|
RootDeviceName: aws.String(s.RootDevice.DeviceName),
|
||||||
VirtualizationType: aws.String(config.AMIVirtType),
|
VirtualizationType: aws.String(config.AMIVirtType),
|
||||||
BlockDeviceMappings: blockDevices,
|
BlockDeviceMappings: blockDevicesExcludingRoot,
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.AMIEnhancedNetworking {
|
if config.AMIEnhancedNetworking {
|
||||||
|
|
Loading…
Reference in New Issue