選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

Tagging AWS Device Farm resources

焦點模式
Tagging AWS Device Farm resources - Device Farm desktop browser testing
此頁面尚未翻譯為您的語言。 請求翻譯

AWS Device Farm works with the AWS Resource Groups Tagging API. This API allows you to manage resources in your AWS account with tags. You can add tags to resources, such as projects and test runs.

You can use tags to:

  • Organize your AWS bill to reflect your own cost structure. To do this, sign up to get your AWS account bill with tag key values included. Then, to see the cost of combined resources, organize your billing information according to resources with the same tag key values. For example, you can tag several resources with an application name, and then organize your billing information to see the total cost of that application across several services. For more information, see Cost Allocation and Tagging in About AWS Billing and Cost Management.

  • Control access through IAM policies. To do so, create a policy that allows access to a resource or set of resources using a tag value condition.

  • Identify and manage runs that have certain properties as tags, such as the branch used for testing.

For more information about tagging resources, see the Tagging Best Practices whitepaper.

Tagging resources

The AWS Resource Group Tagging API allows you to add, remove, or modify tags on resources. For more information, see the AWS Resource Group Tagging API Reference.

To tag a resource, use the TagResources operation from the resourcegroupstaggingapi endpoint. This operation takes a list of ARNs from supported services and a list of key-value pairs. The value is optional. An empty string indicates that there should be no value for that tag. For example, the following Python example tags a series of project ARNs with the tag build-config with the value release:

import boto3 client = boto3.client('resourcegroupstaggingapi') client.tag_resources(ResourceARNList=["arn:aws:devicefarm:us-west-2:111122223333:project:123e4567-e89b-12d3-a456-426655440000", "arn:aws:devicefarm:us-west-2:111122223333:project:123e4567-e89b-12d3-a456-426655441111", "arn:aws:devicefarm:us-west-2:111122223333:project:123e4567-e89b-12d3-a456-426655442222"] Tags={"build-config":"release", "git-commit":"8fe28cb"})

A tag value is not required. To set a tag with no value, use an empty string ("") when specifying a value. A tag can only have one value. Any previous value a tag has for a resource will be overwritten with the new value.

Looking up resources by tag

To look up resources by their tags, use the GetResources operation from the resourcegrouptaggingapi endpoint. This operation takes a series of filters, none of which are required, and returns the resources that match the given criteria. With no filters, all tagged resources are returned. The GetResources operation allows you to filter resources based on

  • Tag value

  • Resource type (for example, devicefarm:run)

For more information, see the AWS Resource Group Tagging API Reference.

The following example looks up Device Farm desktop browser testing sessions (devicefarm:testgrid-session resources) with the tag stack that have the value production:

import boto3 client = boto3.client('resourcegroupstaggingapi') sessions = client.get_resources(ResourceTypeFilters=['devicefarm:testgrid-session'], TagFilters=[ {"Key":"stack","Values":["production"]} ])

Removing tags from resources

To remove a tag, use the UntagResources operation, specifying a list of resources and the tags to remove:

import boto3 client = boto3.client('resourcegroupstaggingapi') client.UntagResources(ResourceARNList=["arn:aws:devicefarm:us-west-2:111122223333:project:123e4567-e89b-12d3-a456-426655440000"], TagKeys=["RunCI"])
隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。