Skip to content

Commit 0688575

Browse files
committed
Skip the aws internal tags
1 parent e5b01de commit 0688575

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

pkg/cloud/converters/tags.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package converters
1818

1919
import (
2020
"sort"
21+
"strings"
2122

2223
"github.com/aws/aws-sdk-go/aws"
2324
"github.com/aws/aws-sdk-go/service/autoscaling"
@@ -31,6 +32,11 @@ import (
3132
infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
3233
)
3334

35+
const (
36+
// AwsInternalTagPrefix is the prefix for AWS internal tags, which are reserved for internal AWS use.
37+
AwsInternalTagPrefix = "aws:"
38+
)
39+
3440
// TagsToMap converts a []*ec2.Tag into a infrav1.Tags.
3541
func TagsToMap(src []*ec2.Tag) infrav1.Tags {
3642
tags := make(infrav1.Tags, len(src))
@@ -58,12 +64,14 @@ func MapToTags(src infrav1.Tags) []*ec2.Tag {
5864
tags := make([]*ec2.Tag, 0, len(src))
5965

6066
for k, v := range src {
61-
tag := &ec2.Tag{
62-
Key: aws.String(k),
63-
Value: aws.String(v),
64-
}
67+
if !strings.HasPrefix(k, AwsInternalTagPrefix) {
68+
tag := &ec2.Tag{
69+
Key: aws.String(k),
70+
Value: aws.String(v),
71+
}
6572

66-
tags = append(tags, tag)
73+
tags = append(tags, tag)
74+
}
6775
}
6876

6977
// Sort so that unit tests can expect a stable order

0 commit comments

Comments
 (0)