Longest Retention Period in a Bucket
    • 05 Jun 2024
    • 1 Minute to read
    • PDF

    Longest Retention Period in a Bucket

    • PDF

    Article summary

    How do I find the longest Retention Period I have in my Object Lock Bucket?

    When attempting to delete a bucket with the Object Locking feature enabled, the deletion action could fail if at least one object has one version that is still under object locking and the retention period has not expired (it is an active retention). When dealing with a large bucket that you want to delete, it may be difficult to determine 1) if a bucket has objects that are still under retention and 2) the longest retention period. 

    Wasabi developed a Python script that can analyze your bucket so you can plan the bucket deletion. The script:

    • Detects objects that are still under retention, and 

    • Specifies which object has the longest retention period.

    Prerequisites

    Script Executions and Details

    1. When you execute the script, it will read the profiles identified in your .aws/credentials file and prompt you to select the profile or enter the API keys of the administrator who is executing this script.

      • Press 1 if you already have a profile configured on your CLI.
        You may configure the AWS CLI profile for the Wasabi account beforehand using the Wasabi keys.

        It is optional for you to use credential files to run your code, but it is always a best practice to use such implementation where your credential keys are in a file stored on your local machine rather than being part of your actual code or entering keys at runtime prompt.

      • Press 2 and enter your API keys if you do not want to use the existing profile.

    2. Enter your own bucket name and prefix (if desired). The region will be detected automatically.

      If you specify a prefix, be sure to enter the FULL PREFIX PATH (bucket name NOT included), and the prefix should not start with a forward slash (/). For example:
      folder1/sub-folder/p>

      The script will read the object lock configuration on the specified bucket.

    3. Select Yes or No for the verbose execution of the script:

      • Verbose execution lists all the objects under your bucket.

      • Non Verbose execution analyzes all the objects and only displays the file with the longest retention period expressed in days.

    The output should be similar to:

    mceclip0.png

    Python Script

    You can download the Python script:


    What's Next
    ESC

    Eddy AI, facilitating knowledge discovery through conversational intelligence