diff --git a/builder/amazon/common/run_config.go b/builder/amazon/common/run_config.go index 52289ba50..60124db16 100644 --- a/builder/amazon/common/run_config.go +++ b/builder/amazon/common/run_config.go @@ -69,6 +69,10 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error { c.WindowsPasswordTimeout = 10 * time.Minute } + if c.RunTags == nil { + c.RunTags = make(map[string]string) + } + // Validation errs := c.Comm.Prepare(ctx) if c.SourceAmi == "" && c.SourceAmiFilter.Empty() { diff --git a/builder/amazon/common/step_create_tags.go b/builder/amazon/common/step_create_tags.go index 87ce08840..4de8e50c3 100644 --- a/builder/amazon/common/step_create_tags.go +++ b/builder/amazon/common/step_create_tags.go @@ -31,9 +31,9 @@ func (s *StepCreateTags) Run(state multistep.StateBag) multistep.StepAction { ui.Say(fmt.Sprintf("Adding tags to AMI (%s)...", ami)) // Convert tags to ec2.Tag format - amiTags := ConvertToEC2Tags(s.Tags, ui) + amiTags := ConvertToEC2Tags(s.Tags) ui.Say(fmt.Sprintf("Snapshot tags:")) - snapshotTags := ConvertToEC2Tags(s.SnapshotTags, ui) + snapshotTags := ConvertToEC2Tags(s.SnapshotTags) // Declare list of resources to tag awsConfig := aws.Config{ @@ -128,10 +128,9 @@ func (s *StepCreateTags) Cleanup(state multistep.StateBag) { // No cleanup... } -func ConvertToEC2Tags(tags map[string]string, ui packer.Ui) []*ec2.Tag { +func ConvertToEC2Tags(tags map[string]string) []*ec2.Tag { var amiTags []*ec2.Tag for key, value := range tags { - ui.Message(fmt.Sprintf("Adding tag: \"%s\": \"%s\"", key, value)) amiTags = append(amiTags, &ec2.Tag{ Key: aws.String(key), Value: aws.String(value), diff --git a/builder/amazon/common/step_run_source_instance.go b/builder/amazon/common/step_run_source_instance.go index e436e5aff..649ddfdec 100644 --- a/builder/amazon/common/step_run_source_instance.go +++ b/builder/amazon/common/step_run_source_instance.go @@ -295,7 +295,7 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi if _, exists := s.Tags["Name"]; !exists { s.Tags["Name"] = "Packer Builder" } - ec2Tags := ConvertToEC2Tags(s.Tags, ui) + ec2Tags := ConvertToEC2Tags(s.Tags) _, err = ec2conn.CreateTags(&ec2.CreateTagsInput{ Tags: ec2Tags, diff --git a/builder/amazon/ebs/step_tag_ebs_volumes.go b/builder/amazon/ebs/step_tag_ebs_volumes.go index a9ead9ebe..6db6c3bb6 100644 --- a/builder/amazon/ebs/step_tag_ebs_volumes.go +++ b/builder/amazon/ebs/step_tag_ebs_volumes.go @@ -34,7 +34,7 @@ func (s *stepTagEBSVolumes) Run(state multistep.StateBag) multistep.StepAction { } ui.Say(fmt.Sprintf("Adding tags to source EBS Volumes:")) - tags := common.ConvertToEC2Tags(s.VolumeRunTags, ui) + tags := common.ConvertToEC2Tags(s.VolumeRunTags) _, err := ec2conn.CreateTags(&ec2.CreateTagsInput{ Resources: []*string{