Skip to content

Commit

Permalink
add tags at the time volume is created
Browse files Browse the repository at this point in the history
  • Loading branch information
Kun483 committed Nov 7, 2024
1 parent 1f66f27 commit be7d9ad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/cloud/services/ec2/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down

0 comments on commit be7d9ad

Please sign in to comment.