【问题标题】:AWS resource tagging (python/boto3)AWS 资源标记 (python/boto3)
【发布时间】:2021-03-22 21:34:43
【问题描述】:

使用boto3,几乎每个AWS资源都有不同的标记方法[例如,见1]。

是否有库提供统一的编程接口来标记任何(或几乎任何)类型的 AWS 资源?

[1] 示例: EC2 使用 create_tags()delete_tags()describe_tags() S3 使用 delete_bucket_tagging()get_bucket_tagging()put_bucket_tagging() ...

...所有资源的不同功能...

【问题讨论】:

    标签: python amazon-web-services boto3 tagging


    【解决方案1】:

    在 boto3 中,您可以使用 ResourceGroupsTaggingAPI 方法 tag_resources()。用于将一个或多个标签应用于指定的资源列表。 考虑到并非所有资源都可以有标签并且仅限于特定区域。 同样,还有一种方法可以取消标记资源列表:untag_resources()


    官方文档:

    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

    【讨论】:

    • 太棒了!我会尝试一下!谢谢!
    猜你喜欢
    • 2019-06-22
    • 2022-11-21
    • 2022-11-05
    • 2019-12-24
    • 1970-01-01
    • 2015-11-29
    • 2021-07-01
    • 2019-05-11
    • 1970-01-01
    相关资源
    最近更新 更多