From c717765154d0abced1f988d40f133d42ed57c2af Mon Sep 17 00:00:00 2001 From: cstuntz Date: Wed, 2 Aug 2017 09:29:47 -0700 Subject: [PATCH] Removing tagging post instance launch --- .../amazon/common/step_run_source_instance.go | 30 ++----------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/builder/amazon/common/step_run_source_instance.go b/builder/amazon/common/step_run_source_instance.go index 2e024e40c..12de73adb 100644 --- a/builder/amazon/common/step_run_source_instance.go +++ b/builder/amazon/common/step_run_source_instance.go @@ -9,10 +9,8 @@ import ( "time" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/ec2" - retry "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" "github.com/mitchellh/multistep" @@ -143,6 +141,8 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi return multistep.ActionHalt } + ReportTags(ui, ec2Tags) + if spotPrice == "" || spotPrice == "0" { var runTag ec2.TagSpecification @@ -298,32 +298,6 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi s.Tags["Name"] = "Packer Builder" } - ReportTags(ui, ec2Tags) - - // Retry creating tags for about 2.5 minutes - err = retry.Retry(0.2, 30, 11, func(_ uint) (bool, error) { - _, err := ec2conn.CreateTags(&ec2.CreateTagsInput{ - Tags: ec2Tags, - Resources: []*string{instance.InstanceId}, - }) - if err == nil { - return true, nil - } - if awsErr, ok := err.(awserr.Error); ok { - if awsErr.Code() == "InvalidInstanceID.NotFound" { - return false, nil - } - } - return true, err - }) - - if err != nil { - err := fmt.Errorf("Error tagging source instance: %s", err) - state.Put("error", err) - ui.Error(err.Error()) - return multistep.ActionHalt - } - if s.Debug { if instance.PublicDnsName != nil && *instance.PublicDnsName != "" { ui.Message(fmt.Sprintf("Public DNS: %s", *instance.PublicDnsName))