Create a Bucket with Object Lock
In this tutorial, you will learn how to create a Bucket with Object Lock using the IONOS Object Storage API.
Target audience
This tutorial is intended for developers and system administrators who are using AWS CLI or PowerShell to manage Object Storage compatible services. It assumes you have basic knowledge of the following:
AWS S3 services
Command line interfaces like AWS CLI and PowerShell
Object Lock feature for data protection
What you will learn
By the end of this tutorial, you will be able to:
Set up and configure AWS CLI and PowerShell for use with IONOS Object Storage.
Create a 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 Object Storage
Access Key IDandSecret Access Key.Be familiar with basic commands in AWS CLI and PowerShell.
Procedure
To begin creating a bucket with Object Lock, configure your local environment for IONOS Object Storage access.
Configure AWS CLI with IONOS Object Storage
Use the aws configure command to set up your access credentials and default region. You also need to specify the endpoint URL per request.
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]: jsonCreate a new bucket with Object Lock enabled
The following commands only enable Object Lock at the bucket level without default settings.
a. Using AWS CLI
Execute the following command to create a new bucket:
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-1b. 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-S3Enable Default Object Lock Configuration (if required)
a. Using AWS CLI
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-S3Final result
Object lock is enabled for a newly created bucket using IONOS Object Storage API, AWS CLI, or Powershell commands.
Conclusion
In this tutorial, you learned how to:
Configure AWS CLI and PowerShell for IONOS Object Storage.
Create a 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 Object Storage:
Learn how to manage Object Lock settings on existing objects.
Explore other advanced bucket configurations.
Last updated
Was this helpful?