Managing bucket versioning
Bucket versioning makes it possible to store object history through versions.
Note
You cannot disable versioning once you enable it, but you can pause the creation of new versions. After you pause versioning, new objects will be saved as null
versions.
Enable bucket versioning:
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
View a description of the CLI command to edit a bucket ACL:
yc storage bucket update --help
-
Run the following command:
yc storage bucket update --name <bucket_name> --versioning versioning-enabled
Result:
name: my-bucket folder_id: csgeoelk7fl15******** default_storage_class: STANDARD versioning: VERSIONING_ENABLED max_size: "10737418240" acl: {} created_at: "2022-12-14T08:42:16.273717Z"
If you do not have the AWS CLI yet, install and configure it.
Run the following command:
aws --endpoint https://storage.yandexcloud.net \
s3api put-bucket-versioning \
--bucket <bucket_name> \
--versioning-configuration 'Status=Enabled'
If you don't have Terraform, install it and configure the Yandex Cloud provider.
Retrieve static access keys: a static key and a key ID used to authenticate in Object Storage.
In the configuration file, describe the parameters of the resources you want to create:
resource "yandex_storage_bucket" "b" {
bucket = "<bucket_name>"
access_key = "<key_ID>"
secret_key = "<secret_key>"
acl = "private"
versioning {
enabled = true
}
}
Where:
bucket
: Bucket name. This is a required parameter.access_key
: ID of the static access key.secret_key
: Value of the secret access key.acl
: Applied ACL policy. The default value isprivate
. This is an optional parameter.versioning
: Bucket versioning management:enabled
: Enables bucket versioning. This is an optional parameter.
To manage bucket versioning, use the update REST API method for the Bucket resource, the BucketService/Update gRPC API call, or the putBucketVersioning S3 API method.