更新 Storage Lens 群組 - Amazon Simple Storage Service

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

更新 Storage Lens 群組

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

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

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

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

  4. 範圍底下,選擇編輯

  5. 範圍頁面上,選取要套用至 Storage Lens 群組的篩選條件。若要套用多個篩選條件,請選取篩選條件,然後選擇 ANDOR 邏輯運算子。

    • 針對字首篩選條件,選取字首,然後輸入字首字串。若要新增多個字首,請選擇新增字首。若要移除字首,請選擇要移除的字首旁的移除

    • 針對物件標籤篩選條件,輸入物件的鍵/值對。然後,選擇新增標籤。若要移除標籤,請選擇要移除的標籤旁的移除

    • 針對尾碼篩選條件,選取尾碼,然後輸入尾碼字串。若要新增多個尾碼,請選擇新增尾碼。若要移除尾碼,請選擇要移除的尾碼旁的移除

    • 針對存留期篩選條件,指定物件存留期範圍 (天數)。選擇指定最短物件存留期,然後輸入最短的物件存留期。針對指定最長物件存留期,輸入最長的物件存留期。

    • 針對大小篩選條件,指定物件大小範圍和測量單位。選擇指定最小物件大小,然後輸入最小的物件大小。針對指定最大物件大小,輸入最大的物件大小。

  6. 選擇 Save changes (儲存變更)。Storage Lens 群組的詳細資訊頁面隨即出現。

  7. (選用) 如果您要新增 AWS 資源標籤,請捲動至 AWS 資源標籤區段,然後選擇新增標籤Add tags (新增標籤) 頁面隨即出現。

    新增新的鍵/值對,然後選擇儲存變更。Storage Lens 群組的詳細資訊頁面隨即出現。

  8. (選用) 如果要移除現有的 AWS 資源標籤,請捲動至 AWS 資源標籤區段,並選取資源標籤。再選擇 Delete (刪除)。刪除 AWS 標籤對話方塊隨即出現。

    再次選擇刪除,可永久刪除 AWS 資源標籤。

    注意

    AWS 資源標籤永久刪除後,即無法還原。

下列 AWS CLI 範例命令會傳回名為 marketing-department 的 Storage Lens 群組的組態詳細資訊。若要使用此範例命令,請以您自己的資訊取代 user input placeholders

aws s3control get-storage-lens-group --account-id 111122223333 \ --region us-east-1 --name marketing-department

下列 AWS CLI 範例會更新 Storage Lens 群組。若要使用此範例命令,請以您自己的資訊取代 user input placeholders

aws s3control update-storage-lens-group --account-id 111122223333 \ --region us-east-1 --storage-lens-group=file://./marketing-department.json

如需範例 JSON 組態,請參閱 Storage Lens 群組組態

下列 AWS SDK for Java 範例會傳回帳戶 111122223333Marketing-Department 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.GetStorageLensGroupRequest; import software.amazon.awssdk.services.s3control.model.GetStorageLensGroupResponse; public class GetStorageLensGroup { public static void main(String[] args) { String storageLensGroupName = "Marketing-Department"; String accountId = "111122223333"; try { GetStorageLensGroupRequest getRequest = GetStorageLensGroupRequest.builder() .name(storageLensGroupName) .accountId(accountId).build(); S3ControlClient s3ControlClient = S3ControlClient.builder() .region(Region.US_WEST_2) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); GetStorageLensGroupResponse response = s3ControlClient.getStorageLensGroup(getRequest); 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(); } } }

下列範例會更新帳戶 111122223333 中名為 Marketing-Department 的 Storage Lens 群組。此範例會更新儀表板範圍,以包含符合下列任何尾碼的物件:.png.gif.jpg.jpeg。若要使用此範例,請以您自己的資訊取代 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.StorageLensGroup; import software.amazon.awssdk.services.s3control.model.StorageLensGroupFilter; import software.amazon.awssdk.services.s3control.model.UpdateStorageLensGroupRequest; public class UpdateStorageLensGroup { public static void main(String[] args) { String storageLensGroupName = "Marketing-Department"; String accountId = "111122223333"; try { // Create updated filter. StorageLensGroupFilter suffixFilter = StorageLensGroupFilter.builder() .matchAnySuffix(".png", ".gif", ".jpg", ".jpeg") .build(); StorageLensGroup storageLensGroup = StorageLensGroup.builder() .name(storageLensGroupName) .filter(suffixFilter) .build(); UpdateStorageLensGroupRequest updateStorageLensGroupRequest = UpdateStorageLensGroupRequest.builder() .name(storageLensGroupName) .storageLensGroup(storageLensGroup) .accountId(accountId) .build(); S3ControlClient s3ControlClient = S3ControlClient.builder() .region(Region.US_WEST_2) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); s3ControlClient.updateStorageLensGroup(updateStorageLensGroupRequest); } 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(); } } }

如需範例 JSON 組態,請參閱 Storage Lens 群組組態