From 3f036b33c50f7b39f89dc262991643e5d9eabf64 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Mon, 3 Jun 2019 19:14:06 -0700 Subject: [PATCH] test for length of ami tags before tagging --- builder/amazon/common/step_create_tags.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/builder/amazon/common/step_create_tags.go b/builder/amazon/common/step_create_tags.go index 06aa2f356..337bc1daa 100644 --- a/builder/amazon/common/step_create_tags.go +++ b/builder/amazon/common/step_create_tags.go @@ -105,12 +105,16 @@ func (s *StepCreateTags) Run(ctx context.Context, state multistep.StateBag) mult RetryDelay: (&retry.Backoff{InitialBackoff: 200 * time.Millisecond, MaxBackoff: 30, Multiplier: 2}).Linear, }.Run(ctx, func(ctx context.Context) error { // Tag images and snapshots - _, err := regionConn.CreateTags(&ec2.CreateTagsInput{ - Resources: resourceIds, - Tags: amiTags, - }) - if err != nil { - return err + + var err error + if len(amiTags) > 0 { + _, err = regionConn.CreateTags(&ec2.CreateTagsInput{ + Resources: resourceIds, + Tags: amiTags, + }) + if err != nil { + return err + } } // Override tags on snapshots