Create a Bucket with Object Lock
5 min
in this tutorial, you will learn how to create a bucket with object lock using the 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 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 object storage access key id and secret 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 object storage access configure aws cli with 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] json configure powershell with object storage use the set awscredential command in powershell to set up your credentials remember to specify the endpoint url using endpointurl powershell set awscredential accesskey your access key secretkey your secret key storeas ionos s3 create 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 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 enable 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 s3 final result object lock is enabled for a newly created bucket using object storage api, aws cli, or powershell commands conclusion in this tutorial, you learned how to configure aws cli and powershell for 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 object storage learn how to manage object lock https //docs ionos com/cloud/backup and storage/ionos object storage/settings/object lock settings on existing objects explore other advanced bucket configurations
