From be7d9ad62b917382ed25b5026dd49b2826548bc1 Mon Sep 17 00:00:00 2001 From: kun zhou Date: Thu, 7 Nov 2024 09:22:12 -0800 Subject: [PATCH] add tags at the time volume is created --- pkg/cloud/services/ec2/instances.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/cloud/services/ec2/instances.go b/pkg/cloud/services/ec2/instances.go index 454ffe2be4..856857741e 100644 --- a/pkg/cloud/services/ec2/instances.go +++ b/pkg/cloud/services/ec2/instances.go @@ -538,6 +538,7 @@ func (s *Service) runInstance(role string, i *infrav1.Instance) (*infrav1.Instan if len(i.Tags) > 0 { spec := &ec2.TagSpecification{ResourceType: aws.String(ec2.ResourceTypeInstance)} + volumeSpec := &ec2.TagSpecification{ResourceType: aws.String(ec2.ResourceTypeVolume)} // We need to sort keys for tests to work keys := make([]string, 0, len(i.Tags)) for k := range i.Tags { @@ -549,9 +550,14 @@ func (s *Service) runInstance(role string, i *infrav1.Instance) (*infrav1.Instan Key: aws.String(key), Value: aws.String(i.Tags[key]), }) + volumeSpec.Tags = append(volumeSpec.Tags, &ec2.Tag{ + Key: aws.String(key), + Value: aws.String(i.Tags[key]), + }) } input.TagSpecifications = append(input.TagSpecifications, spec) + input.TagSpecifications = append(input.TagSpecifications, volumeSpec) } input.InstanceMarketOptions = getInstanceMarketOptionsRequest(i.SpotMarketOptions)