Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
Yandex Object Storage
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Buckets
      • Creating a bucket
      • Deleting a bucket
      • Limiting the maximum size of a bucket
      • Allowing public access to a bucket
      • Bucket encryption
      • Managing object lifecycles
      • Managing CORS configurations
      • Access policy management
      • Managing bucket versioning
      • Editing the ACL of a bucket
      • Enabling logging
      • Object lock management
    • Objects
      • Uploading an object
      • Getting information about an object
      • Downloading an object
      • Restoring an object's version
      • Getting a public link to an object
      • Configuring an object lock
      • Deleting an object
      • Deleting all objects
      • Deleting a partially uploaded object
      • Editing an object ACL
    • Static website hosting
      • Hosting setup
      • Support for your own domain
      • Support for multiple domain names
      • Configuring HTTPS
  • Tutorials
    • Getting object query statistics with S3 Select
    • Getting website traffic statistics with S3 Select
    • Generating a billing report with resource break-down using S3 Select
    • Server-side encryption
    • Integrating an L7 load balancer with the CDN and Object Storage
    • Blue-green and canary deployment of service versions
    • Analyzing logs in DataLens
    • Using initialization scripts to configure GeeseFS in Yandex Data Proc
    • Mounting a bucket as a disk on Windows
    • Migrating data from Yandex Data Streams using Yandex Data Transfer
  • Concepts
    • Overview
    • Bucket
    • Objects
    • Bucket versioning
    • Object locks
    • Encryption
    • Object lifecycles
    • CORS
    • Static website hosting
    • Pre-signed URLs
    • Multipart upload
    • Access control lists (ACLs)
    • Bucket Policy
    • Uploading files via an HTML form
    • Storage class
    • Logging actions with a bucket
    • Backups
    • TLS protocol
    • S3 Select query language
    • Quotas and limits
  • Tools
    • All tools
    • Console clients
      • AWS CLI
      • S3cmd
    • File browsers
      • CyberDuck
      • WinSCP
    • SDK
      • AWS SDK for Java
      • Python SDK (boto)
      • AWS SDK for .NET
      • AWS SDK for C++
      • AWS SDK for PHP
      • AWS SDK for Go
    • FUSE
      • GeeseFS
      • s3fs
      • goofys
    • FTP
      • Docker container for (S)FTP(S)
  • API reference
    • REST (Amazon S3-compatible)
      • How to use the API
      • Signing requests
      • REST
        • All services and methods
        • Bucket
          • All methods
          • create
          • getBucketEncryption
          • getMeta
          • listObjects
          • listBuckets
          • deleteBucket
          • deleteBucketEncryption
          • putBucketEncryption
          • putBucketVersioning
          • getBucketVersioning
          • putBucketLogging
          • getBucketLogging
          • listObjectVersions
          • putObjectLockConfiguration
          • getObjectLockConfiguration
        • Object
          • All methods
          • upload
          • get
          • copy
          • getObjectMeta
          • delete
          • deleteMultipleObjects
          • options
          • selectObjectContent
          • putObjectRetention
          • putObjectLegalHold
          • getObjectRetention
          • getObjectLegalHold
        • Multipart upload
          • General multipart upload procedure
          • startUpload
          • uploadPart
          • copyPart
          • listParts
          • abortUpload
          • completeUpload
          • listUploads
        • Static Website Hosting
          • All methods
          • upload
          • get
          • delete
          • Static website response codes
        • CORS
          • All methods
          • XML structure of CORS configuration
          • upload
          • get
          • delete
        • Lifecycles
          • All methods
          • XML structure of lifecycle configuration
          • upload
          • get
          • delete
        • ACL
          • All methods
          • XML structure of ACL configuration
          • objectGetAcl
          • objectPutAcl
          • bucketGetAcl
          • bucketPutAcl
        • Bucket Policy
          • All methods
          • GetBucketPolicy
          • PutBucketPolicy
          • DeleteBucketPolicy
          • Data schema
          • Actions
          • Conditions
        • Common request headers
        • Common response headers
        • Responses
    • gRPC and REST
      • Authentication in the API
      • gRPC
        • Overview
        • BucketService
        • OperationService
      • REST
        • Overview
        • Bucket
          • Overview
          • create
          • delete
          • deleteHTTPSConfig
          • get
          • getHTTPSConfig
          • getStats
          • list
          • setHTTPSConfig
          • update
  • Access management
  • Pricing policy
    • Current pricing policy
    • Archive
      • Before January 1, 2019
      • From January 1 to March 1, 2019
  • Questions and answers
  1. Step-by-step instructions
  2. Buckets
  3. Object lock management

Managing object lock in buckets

Written by
Yandex Cloud
  • Enabling an object lock
  • Setting up default object locks
  • Disabling object locks

You can set up object lock in versioned buckets. When object lock is enabled, you can lock an object version so that it can't be deleted or overwritten. You can also set default object locks for a bucket: they will apply to all new object versions.

Note

To start using locks in your cloud, request this feature from support.

Enabling an object lock

When you enable locks, previously uploaded object versions aren't locked (but you can lock them).

The minimum required role is storage.admin.

To enable object locks:

AWS CLI
API

If you don't have the AWS CLI yet, install and configure it.

Run the following command:

aws --endpoint-url=https://storage.yandexcloud.net/ \
  s3api put-object-lock-configuration \
  --bucket <bucket_name> \
  --object-lock-configuration ObjectLockEnabled=Enabled

Where:

  • bucket: Bucket name.

  • object-lock-configuration: Lock configuration in the bucket:

    • ObjectLockEnabled=Enabled: Object lock is enabled.

Use the putObjectLockConfiguration method.

Setting up default object locks

Default locks are set for all new object versions uploaded to the bucket. These settings don't affect previously uploaded versions.

The minimum required role is storage.admin.

To set up default object locks:

AWS CLI

If you don't have the AWS CLI yet, install and configure it.

  1. Specify a configuration for default object locks in JSON format:

    {
      "ObjectLockEnabled": "Enabled",
      "Rule": {
        "DefaultRetention": {
          "Mode": "<lock_type>",
          "Days": <lock_period_in_days>,
          "Years": <lock_period_in_years>
        }       
      }
    }
    

    Where:

    • ObjectLockEnabled Object lock status: Enabled: Object lock is enabled.

      Alert

      This is a required field. If you omit Enabled in this parameter, object locks will be disabled.

    • Mode is the type of object lock:

      • GOVERNANCE: An object lock with a predefined retention period that can be managed.
      • COMPLIANCE: An object lock with a predefined retention period with strict compliance.
    • Days: The retention period in days after uploading an object version. It must be a positive integer. You can't set it simultaneously with Years.

    • Years: The retention period in years after uploading an object version. It must be a positive integer. You can't set it simultaneously with Days.

    When you're done, you can save your configuration as a file, like default-object-lock.json.

  2. Upload the configuration to the bucket:

    aws --endpoint-url=https://storage.yandexcloud.net/ \
      s3api put-object-lock-configuration \
      --bucket <bucket_name> \
      --object-lock-configuration file://default-object-lock.json
    

    Where:

    • bucket: Bucket name.
    • object-lock-configuration: Default object lock configuration. In this case, specified in the default-object-lock.json file.

Disabling object locks

If you disable object locks, this doesn't disable the locks put previously. Such locks are still in effect, and you can't remove or change them.

The minimum required role is storage.admin.

To disable object locks:

AWS CLI

If you don't have the AWS CLI yet, install and configure it.

Run the following command:

aws --endpoint-url=https://storage.yandexcloud.net/ \
  s3api put-object-lock-configuration \
  --bucket <bucket_name> \
  --object-lock-configuration ""

Where:

  • bucket: Bucket name.
  • object-lock-configuration: Lock configuration in the bucket. An empty value disables object locks.

Was the article helpful?

Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
In this article:
  • Enabling an object lock
  • Setting up default object locks
  • Disabling object locks