从 Storage Lens 组删除 Amazon 资源标签
以下示例演示如何从 Storage Lens 组删除 Amazon 资源标签。您可以使用 Amazon S3 控制台、Amazon Command Line Interface (Amazon CLI) 和 适用于 Java 的 Amazon SDK 删除标签。
从 Storage Lens 组删除 Amazon 资源标签
登录到Amazon Web Services Management Console,然后通过以下网址打开 Amazon S3 控制台:https://console.aws.amazon.com/s3/
。 -
在左侧导航窗格中,选择 Storage Lens 组。
-
在 Storage Lens 组下,选择要更新的 Storage Lens 组。
-
在 Amazon 资源标签下,选择要删除的键值对。
-
选择删除。将出现删除 Amazon 资源标签对话框。
注意
如果使用标签控制访问,则继续执行此操作可能会影响相关资源。永久删除标签后,该标签将无法还原。
-
选择删除,永久性删除该键值对。
以下 Amazon CLI 命令将从现有 Storage Lens 组中删除两个 Amazon 资源标签:要使用此示例命令,请将
替换为您自己的信息。user input placeholders
aws s3control untag-resource --account-id
111122223333
\ --resource-arn arn:aws:s3:us-east-1
:111122223333
:storage-lens-group/Marketing-Department
\ --regionus-east-1
--tag-keysk1
k2
以下 适用于 Java 的 Amazon SDK 示例将从账户
中具有您所指定的 Amazon 资源名称 (ARN) 的 Storage Lens 组中,删除两个 Amazon 资源标签。要使用此示例,请将 111122223333
替换为您自己的信息。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.UntagResourceRequest; public class UntagResource { public static void main(String[] args) { String resourceARN = "
Resource_ARN
"; String accountId = "111122223333
"; try { String tagKey1 = "resource-tag-key-1
"; String tagKey2 = "resource-tag-key-2
"; UntagResourceRequest untagResourceRequest = UntagResourceRequest.builder() .resourceArn(resourceARN
) .tagKeys(tagKey1
,tagKey2
) .accountId(accountId
) .build(); S3ControlClient s3ControlClient = S3ControlClient.builder() .region(Region.US_WEST_2
) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); s3ControlClient.untagResource(untagResourceRequest); } 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(); } } }