列出 Storage Lens 组标签
以下示例演示如何列出与 Storage Lens 组关联的 Amazon 资源标签。您可以使用 Amazon S3 控制台、Amazon Command Line Interface (Amazon CLI) 和 适用于 Java 的 Amazon SDK 列出标签。
查看 Storage Lens 组的标签和标签值列表
登录到 Amazon Web Services Management Console,然后通过以下网址打开 Amazon S3 控制台:https://console.aws.amazon.com/s3/
。 -
在左侧导航窗格中,选择 Storage Lens 组。
-
在 Storage Lens 组下,选择您感兴趣的 Storage Lens 组。
-
向下滚动到 Amazon 资源标签部分。所有添加到您的 Storage Lens 组的用户定义的 Amazon 资源标签及其标签值都将列出。
以下 Amazon CLI 示例命令将列出名为
的 Storage Lens 组的所有 Storage Lens 组标签值。要使用此示例命令,请将 marketing-department
替换为您自己的信息。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
\ --regionus-east-1
以下 适用于 Java 的 Amazon SDK 示例将为您指定的 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(); } } }