Add spot tags as resource tags of instances and volumes in launch template
According to the APIReference: <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_LaunchTemplateTagSpecificationRequest.html>, 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.
This commit is contained in:
parent
4b0de7263e
commit
f7e68f1d71
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue