From 50d9546658c87516520f12fdf48e6c196bd89592 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 9 Mar 2017 14:24:49 -0800 Subject: [PATCH] builder/amazon: set force_deregister to true on -force --- builder/amazon/chroot/builder.go | 4 ++++ builder/amazon/ebs/builder.go | 4 ++++ builder/amazon/ebssurrogate/builder.go | 4 ++++ builder/amazon/instance/builder.go | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 18bf8ce3c..17f725212 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -78,6 +78,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { return nil, err } + if b.config.PackerConfig.PackerForce { + b.config.AMIForceDeregister = true + } + // Defaults if b.config.ChrootMounts == nil { b.config.ChrootMounts = make([][]string, 0) diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 13598b96a..c36cb33e8 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -58,6 +58,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { return nil, err } + if b.config.PackerConfig.PackerForce { + b.config.AMIForceDeregister = true + } + // Accumulate any errors var errs *packer.MultiError errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index df2db83c1..b3b02aeab 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -58,6 +58,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { return nil, err } + if b.config.PackerConfig.PackerForce { + b.config.AMIForceDeregister = true + } + // Accumulate any errors var errs *packer.MultiError errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...) diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index ce5664d26..d1e6c50a0 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -77,6 +77,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { return nil, err } + if b.config.PackerConfig.PackerForce { + b.config.AMIForceDeregister = true + } + if b.config.BundleDestination == "" { b.config.BundleDestination = "/tmp" }