builder/amazon: Raise error when ebsvolume kms_key_id is without encrypted = true

This commit is contained in:
Jason Wieringa 2018-01-11 20:26:44 -08:00
parent 2ac59b3c27
commit f6772f06be
1 changed files with 8 additions and 0 deletions

View File

@ -57,6 +57,14 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...) errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
// Warn that encrypted must be true when setting kms_key_id
for _, device := range b.config.VolumeMappings {
if device.KmsKeyId != "" && device.Encrypted == false {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The device %v, must also have `encrytped: "+
"true` when setting a kms_key_id.", device.DeviceName))
}
}
b.config.launchBlockDevices, err = commonBlockDevices(b.config.VolumeMappings, &b.config.ctx) b.config.launchBlockDevices, err = commonBlockDevices(b.config.VolumeMappings, &b.config.ctx)
if err != nil { if err != nil {
errs = packer.MultiErrorAppend(errs, err) errs = packer.MultiErrorAppend(errs, err)