Skip to content

Commit 8f30044

Browse files
committedFeb 29, 2024·
ec2/tags: Add convenience func
1 parent d7938bf commit 8f30044

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
 

‎internal/service/ec2/tags.go

+28
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ func tagSpecificationsFromMap(ctx context.Context, m map[string]interface{}, t s
5151
}
5252
}
5353

54+
// tagSpecificationsFromMap returns the tag specifications for the given tag key/value map and resource type.
55+
func tagSpecificationsFromKeyValue(ctx context.Context, tags tftags.KeyValueTags, resourceType string) []*ec2.TagSpecification {
56+
if len(tags) == 0 {
57+
return nil
58+
}
59+
60+
return []*ec2.TagSpecification{
61+
{
62+
ResourceType: aws.String(resourceType),
63+
Tags: Tags(tags.IgnoreAWS()),
64+
},
65+
}
66+
}
67+
5468
// getTagSpecificationsIn returns AWS SDK for Go v1 EC2 service tags from Context.
5569
// nil is returned if there are no input tags.
5670
func getTagSpecificationsIn(ctx context.Context, resourceType string) []*ec2.TagSpecification {
@@ -92,3 +106,17 @@ func tagsSchemaConflictsWith(conflictsWith []string) *schema.Schema {
92106

93107
return v
94108
}
109+
110+
// tagSpecificationsFromMap returns the tag specifications for the given tag key/value map and resource type.
111+
func resolveDuplicate(ctx context.Context, m map[string]interface{}, t string) []*ec2.TagSpecification {
112+
if len(m) == 0 {
113+
return nil
114+
}
115+
116+
return []*ec2.TagSpecification{
117+
{
118+
ResourceType: aws.String(t),
119+
Tags: Tags(tftags.New(ctx, m).IgnoreAWS()),
120+
},
121+
}
122+
}

0 commit comments

Comments
 (0)
Please sign in to comment.