From f7e68f1d711ca4fcc2f1e0562a63e41566fa500b Mon Sep 17 00:00:00 2001 From: Narthana Epa Date: Sat, 9 Jan 2021 23:58:23 +1100 Subject: [PATCH] Add spot tags as resource tags of instances and volumes in launch template According to the APIReference: , the resource types `instance` and `volume` support tagging on creation. It is useful to add the spot tags here as it should be more reliable than tagging them after the spot request is fulfilled as we currently do. --- builder/amazon/common/step_run_spot_instance.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/builder/amazon/common/step_run_spot_instance.go b/builder/amazon/common/step_run_spot_instance.go index 210498eef..58ebec885 100644 --- a/builder/amazon/common/step_run_spot_instance.go +++ b/builder/amazon/common/step_run_spot_instance.go @@ -260,6 +260,16 @@ func (s *StepRunSpotInstance) Run(ctx context.Context, state multistep.StateBag) Tags: spotTags, }, } + launchTemplate.LaunchTemplateData.TagSpecifications = []*ec2.LaunchTemplateTagSpecificationRequest{ + { + ResourceType: aws.String("instance"), + Tags: spotTags, + }, + { + ResourceType: aws.String("volume"), + Tags: spotTags, + }, + } } // Tell EC2 to create the template