Create Object Lock

Overview

In this tutorial, you'll learn how to create a Bucket with Object Lock using the IONOS S3 API. This tutorial is intended for developers and system administrators who are using AWS CLI or PowerShell to manage S3 compatible services. It assumes you have basic knowledge of:

  • AWS S3 services

  • Command line interfaces like AWS CLI and PowerShell

  • Object Lock feature for data protection

By the end of this tutorial, you'll be able to:

  • Set up and configure AWS CLI and PowerShell for use with IONOS S3.

  • Create an S3 bucket with Object Lock enabled on creation.

  • Configure default object lock settings on your new bucket.

Before you begin

Before you start the tutorial, you should:

  • Have the AWS CLI and PowerShell installed on your system.

  • Obtain your IONOS S3 Access Key ID and Secret Access Key.

  • Be familiar with basic commands in AWS CLI and PowerShell.

Creating a Bucket with Object Lock

To get started, ensure your local environment is configured for IONOS S3.

  1. Configure AWS CLI with IONOS S3:

    Use the aws configure command to set up your access credentials and default region.

    aws configure
    AWS Access Key ID [None]: ENTER_YOUR_ACCESS_KEY
    AWS Secret Access Key [None]: ENTER_YOUR_SECRET_KEY
    Default region name [None]: eu-central-1
    Default output format [None]: json

    You also need to specify the endpoint URL per request.

  2. Configure PowerShell with IONOS S3:

    Use the Set-AWSCredential command in PowerShell to set up your credentials.

    Set-AWSCredential -AccessKey YOUR_ACCESS_KEY -SecretKey YOUR_SECRET_KEY -StoreAs IONOS-S3

    Remember to specify the endpoint URL using -EndpointUrl.

  3. Create a new bucket with Object Lock enabled:

    a. Using AWS CLI:

    Execute the following command to create a new bucket:
    
    ```bash
    aws s3api create-bucket --bucket YOUR_BUCKET_NAME --object-lock-enabled-for-bucket --endpoint-url https://s3-eu-central-1.ionoscloud.com --create-bucket-configuration LocationConstraint=eu-central-1
    ```

    b. Using PowerShell:

    Use this PowerShell command:
    
    ```powershell
    New-S3Bucket -BucketName YOUR_BUCKET_NAME -ObjectLockEnabledForBucket $true -EndpointUrl "https://s3-eu-central-1.ionoscloud.com" -ProfileName IONOS-S3
    ```

    These commands only enable Object Lock at the bucket level without default settings.

  4. Enable Default Object Lock Configuration (if required):

    a. Using AWS CLI:

    ```bash
    aws s3api put-object-lock-configuration --bucket YOUR_BUCKET_NAME --object-lock-configuration '{"ObjectLockEnabled": "Enabled", "Rule": {"DefaultRetention": {"Mode": "COMPLIANCE", "Days": 50}}}'
    ```

    b. Using PowerShell:

    ```powershell
    Write-S3ObjectLockConfiguration -BucketName YOUR_BUCKET_NAME -ObjectLockConfiguration_ObjectLockEnabled Enabled -DefaultRetention_Mode COMPLIANCE -DefaultRetention_Days 50 -EndpointUrl "https://s3-eu-central-1.ionoscloud.com" -ProfileName IONOS-S3
    ```

Summary

In this tutorial, you learned how to:

  • Configure AWS CLI and PowerShell for IONOS S3.

  • Create an S3 bucket with Object Lock enabled at creation.

  • Apply default object lock settings to secure the contents of your bucket.

Next steps

Consider exploring additional configurations and features of IONOS S3:

  • Learn how to manage Object Lock settings on existing objects.

  • Explore other advanced S3 bucket configurations.

Last updated

Was this helpful?