本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
從 Storage Lens 群組中刪除 AWS 資源標籤
下列範例示範如何從 Storage Lens 群組中刪除 AWS 資源標籤。您可以使用 Amazon S3 主控台、AWS Command Line Interface (AWS CLI) 和 AWS SDK for Java 來刪除標籤。
從 Storage Lens 群組中刪除 AWS 資源標籤
登入 AWS Management Console,並開啟位於 https://console.aws.amazon.com/s3/
的 Amazon S3 主控台。 -
在左側導覽窗格中,選擇 Storage Lens 群組。
-
在 Storage Lens 群組底下,選擇您要更新的 Storage Lens 群組。
-
在 AWS 資源標籤底下,選取您要刪除的鍵/值對。
-
選擇 Delete (刪除)。刪除 AWS 資源標籤對話方塊隨即出現。
注意
如果標籤用來控制存取,繼續執行此動作可能會影響到相關資源。標籤永久刪除後,即無法還原。
-
選擇刪除,永久刪除鍵/值對。
下列 AWS CLI 命令會從現有的 Storage Lens 群組中刪除兩個 AWS 資源標籤:若要使用此範例命令,請將
取代為您自己的資訊。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
下列 AWS SDK for Java 範例會從您在帳戶
中指定的 Storage Lens 群組 Amazon 資源名稱 (ARN) 刪除兩個 AWS 資源標籤。若要使用此範例,請以您自己的資訊取代 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(); } } }