更新 Storage Lens 群組標籤值 - Amazon Simple Storage Service

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

更新 Storage Lens 群組標籤值

下列範例示範如何使用 Amazon S3 主控台、AWS Command Line Interface (AWS CLI) 和 AWS SDK for Java 更新 Storage Lens 群組標籤值。

更新 Storage Lens 群組的 AWS 資源標籤
  1. 登入 AWS Management Console,並開啟位於 https://console.aws.amazon.com/s3/ 的 Amazon S3 主控台。

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

  3. Storage Lens 群組底下,選擇您要更新的 Storage Lens 群組。

  4. AWS 資源標籤底下,選取您要更新的標籤。

  5. 使用與您要更新的鍵/值對相同的索引鍵,新增新的標籤值。選擇更新標籤值的核取記號圖示。

    注意

    新增與現有標籤具有相同的索引鍵的標籤,將會覆寫先前的標籤值。

  6. (選用) 如果您要新增標籤,請選擇新增標籤以新增項目。Add tags (新增標籤) 頁面隨即出現。

    您最多可以為 Storage Lens 群組新增最多 50 個 AWS 資源標籤。當您完成新增標籤的作業時,請選擇儲存變更

  7. (選用) 如果您要移除新增的項目,請在移除的標籤旁選擇移除。當您完成移除標籤的作業時,請選擇儲存變更

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

aws s3control tag-resource --account-id 111122223333 \ --resource-arn arn:aws:s3:us-east-1:111122223333:storage-lens-group/marketing-department \ --region us-east-1 --tags Key=k1,Value=v3 Key=k2,Value=v4

下列 AWS SDK for Java 範例會更新兩個 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.Tag; import software.amazon.awssdk.services.s3control.model.TagResourceRequest; public class UpdateTagsForResource { public static void main(String[] args) { String resourceARN = "Resource_ARN"; String accountId = "111122223333"; try { Tag updatedResourceTag1 = Tag.builder() .key("resource-tag-key-1") .value("resource-tag-updated-value-1") .build(); Tag updatedResourceTag2 = Tag.builder() .key("resource-tag-key-2") .value("resource-tag-updated-value-2") .build(); TagResourceRequest tagResourceRequest = TagResourceRequest.builder() .resourceArn(resourceARN) .tags(updatedResourceTag1, updatedResourceTag2) .accountId(accountId) .build(); S3ControlClient s3ControlClient = S3ControlClient.builder() .region(Region.US_WEST_2) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); s3ControlClient.tagResource(tagResourceRequest); } 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(); } } }