@@ -336,6 +336,26 @@ func (c *Cloud) TagResource(ctx context.Context, resourceID string, tags map[str
336336 return nil
337337}
338338
339+ // TagResourceBatch calls EC2 and tag the resource associated to resourceID with the supplied tags
340+ // calls are batched based on batcher configuration.
341+ func (c * Cloud ) TagResourceBatch (ctx context.Context , resourceID string , tags map [string ]string ) error {
342+ request := & ec2.CreateTagsInput {
343+ Resources : []string {resourceID },
344+ Tags : buildAwsTags (tags ),
345+ }
346+
347+ output , err := c .createTagsBatcher .createTags (ctx , request )
348+
349+ if err != nil {
350+ klog .Errorf ("Error occurred trying to tag resources, %v" , err )
351+ return err
352+ }
353+
354+ klog .Infof ("Done calling create-tags to EC2: %v" , output )
355+
356+ return nil
357+ }
358+
339359// UntagResource calls EC2 and tag the resource associated to resourceID
340360// with the supplied tags
341361func (c * Cloud ) UntagResource (ctx context.Context , resourceID string , tags map [string ]string ) error {
@@ -362,6 +382,32 @@ func (c *Cloud) UntagResource(ctx context.Context, resourceID string, tags map[s
362382 return nil
363383}
364384
385+ // UntagResourceBatch calls EC2 and tag the resource associated to resourceID with the supplied tags
386+ // calls are batched based on batcher configuration.
387+ func (c * Cloud ) UntagResourceBatch (ctx context.Context , resourceID string , tags map [string ]string ) error {
388+ request := & ec2.DeleteTagsInput {
389+ Resources : []string {resourceID },
390+ Tags : buildAwsTags (tags ),
391+ }
392+
393+ output , err := c .deleteTagsBatcher .deleteTags (ctx , request )
394+
395+ if err != nil {
396+ // An instance not found should not fail the untagging workflow as it
397+ // would for tagging, since the target state is already reached.
398+ if IsAWSErrorInstanceNotFound (err ) {
399+ klog .Infof ("Couldn't find resource when trying to untag it hence skipping it, %v" , err )
400+ return nil
401+ }
402+ klog .Errorf ("Error occurred trying to untag resources, %v" , err )
403+ return err
404+ }
405+
406+ klog .Infof ("Done calling delete-tags to EC2: %v" , output )
407+
408+ return nil
409+ }
410+
365411func buildAwsTags (tags map [string ]string ) []ec2types.Tag {
366412 var awsTags []ec2types.Tag
367413 for k , v := range tags {
0 commit comments