arod
arod

Reputation: 14112

AWS resource tagging (python/boto3)

Using boto3, almost every AWS resource has a different method for tagging [for examples, see 1].

Is there library that offer an unified programmatic interface for tagging any (or almost any) type of AWS resource?

[1] Examples: EC2 uses create_tags(), delete_tags(), describe_tags() S3 uses delete_bucket_tagging(), get_bucket_tagging(), put_bucket_tagging() ...

... different functions for all resources ...

Upvotes: 2

Views: 7864

Answers (1)

OARP
OARP

Reputation: 4077

In boto3 you can use ResourceGroupsTaggingAPI method tag_resources(). Which is used to apply one or more tags to the specified list of resources. Consider that not all resources can have tags and is limited to a specific region. In the same way there is also a method to untag a list of resources: untag_resources()


Official documentation:

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/resourcegroupstaggingapi.html#ResourceGroupsTaggingAPI.Client.tag_resources

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/resourcegroupstaggingapi.html#ResourceGroupsTaggingAPI.Client.untag_resources

Upvotes: 4

Related Questions