Skip to content

Commit

Permalink
Merge pull request #907 from spectrocloud/volumetags-hotfix
Browse files Browse the repository at this point in the history
volumetags-hotfix: attached tags to the volume when launched
  • Loading branch information
Kun483 authored Nov 5, 2024
2 parents 8010300 + 76ede66 commit 236b83a
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 @@ -561,6 +561,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 @@ -572,9 +573,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 236b83a

Please sign in to comment.