列出 Storage Lens 群組標籤 - Amazon Simple Storage Service

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

列出 Storage Lens 群組標籤

下列範例示範如何列出與 Storage Lens 群組相關聯的 AWS 資源標籤。您可以使用 Amazon S3 主控台、AWS Command Line Interface (AWS CLI) 和 AWS SDK for Java 來列出標籤。

檢閱 Storage Lens 群組的標籤與標籤值清單
  1. 登入 AWS Management Console,並開啟位於 https://console.aws.amazon.com/s3/ 的 Amazon S3 主控台。

  2. 在左側導覽窗格中,選擇 Storage Lens 群組

  3. Storage Lens 群組底下,選擇您感興趣的 Storage Lens 群組。

  4. 向下捲動至 AWS 資源標籤區段。所有新增至 Storage Lens 群組的使用者定義 AWS 資源標籤,都會與其標籤值一起列出。

下列 AWS CLI 範例命令會列出名為 marketing-department 的 Storage Lens 群組的所有 Storage Lens 群組標籤值。若要使用此範例命令,請以您自己的資訊取代 user input placeholders

aws s3control list-tags-for-resource --account-id 111122223333 \ --resource-arn arn:aws:s3:us-east-1:111122223333:storage-lens-group/marketing-department \ --region us-east-1

下列 AWS SDK for Java 範例會列出您指定的 Storage Lens 群組 Amazon 資源名稱 (ARN) 的 Storage Lens 群組標籤值。若要使用此範例,請以您自己的資訊取代 user input placeholders

package aws.example.s3control; import com.amazonaws.AmazonServiceException; import com.amazonaws.SdkClientException; import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3control.S3ControlClient; import software.amazon.awssdk.services.s3control.model.ListTagsForResourceRequest; import software.amazon.awssdk.services.s3control.model.ListTagsForResourceResponse; public class ListTagsForResource { public static void main(String[] args) { String resourceARN = "Resource_ARN"; String accountId = "111122223333"; try { ListTagsForResourceRequest listTagsForResourceRequest = ListTagsForResourceRequest.builder() .resourceArn(resourceARN) .accountId(accountId) .build(); S3ControlClient s3ControlClient = S3ControlClient.builder() .region(Region.US_WEST_2) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); ListTagsForResourceResponse response = s3ControlClient.listTagsForResource(listTagsForResourceRequest); System.out.println(response); } catch (AmazonServiceException e) { // The call was transmitted successfully, but Amazon S3 couldn't process // it and returned an error response. e.printStackTrace(); } catch (SdkClientException e) { // Amazon S3 couldn't be contacted for a response, or the client // couldn't parse the response from Amazon S3. e.printStackTrace(); } } }