builder/amazon: Crashes when multiple EBS vols are used

If you use a new EBS vol (which hasn't any snapshot) Packer crashes when
creating the AMI.

Closes #4303
This commit is contained in:
Rickard von Essen 2016-12-21 15:37:08 +01:00
parent 308a01795c
commit 4b1e014be8
No known key found for this signature in database
GPG Key ID: E0C0327388876CBA
1 changed files with 2 additions and 1 deletions

View File

@ -68,7 +68,8 @@ func (s *stepCreateAMI) Run(state multistep.StateBag) multistep.StepAction {
snapshots := make(map[string][]string)
for _, blockDeviceMapping := range imagesResp.Images[0].BlockDeviceMappings {
if blockDeviceMapping.Ebs != nil {
if blockDeviceMapping.Ebs != nil && blockDeviceMapping.Ebs.SnapshotId != nil {
snapshots[*ec2conn.Config.Region] = append(snapshots[*ec2conn.Config.Region], *blockDeviceMapping.Ebs.SnapshotId)
}
}