Creating a bucket
The minimum role required to create a bucket is storage.editor
. See the role description for details.
- In the management console
, select the folder where you want to create a bucket. - Select Object Storage.
- Click Create bucket.
- On the bucket creation page:
-
Enter a name for the bucket according to the naming requirements.
By default, a bucket with a dot in the name is only available over HTTP. To provide HTTPS support for your bucket, upload your own security certificate to Object Storage.
-
Limit the maximum bucket size, if required.
If the value is
0
, the maximum size is not limited and is similar to the enabled No limit option. -
Select the type of access.
-
Select the default storage class.
-
Add labels, if needed:
- Click Add label.
- Enter a label in
key: value
format. - Click Enter.
-
Click Create bucket to complete the operation.
-
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 create a bucket:
yc storage bucket create --help
-
Create a bucket in the default folder:
yc storage bucket create \ --name <bucket_name> \ --default-storage-class <storage_class> \ --max-size <maximum_bucket_size> \ --public-read \ --public-list \ --public-config-read
Where:
-
--name
: Bucket name. For more information, see Bucket naming rules.By default, a bucket with a dot in the name is only available over HTTP. To provide HTTPS support for your bucket, upload your own security certificate to Object Storage.
-
--default-storage-class
: Storage class. The possible values include:standard
: Standard storagecold
: Cold storageice
: Ice storage
-
--max_size
: Maximum bucket size (bytes)0
: No limit -
--public-read
: Flag to enable public read access to bucket objects. -
--public-list
: Flag to enable public access to view the list of bucket objects. -
--public-config-read
: Flag to enable public read access to the bucket configuration.
The
name
parameter is required. Other parameters are optional. By default, the--max-size
parameter is set to0
and public access to the bucket is disabled.Result:
name: <bucket_name> folder_id: b1gmit33ngp6******** anonymous_access_flags: read: false list: false default_storage_class: STANDARD versioning: VERSIONING_DISABLED max_size: "53687091200" acl: {} created_at: "2022-12-16T14:05:12.196007Z"
-
If you do not have the AWS CLI yet, install and configure it.
In the terminal, run the command below by specifying the bucket name and the Object Storage endpoint:
aws --endpoint-url=https://storage.yandexcloud.net \
s3 mb s3://<bucket_name>
Note
By default, a bucket with a dot in the name is only available over HTTP. To provide HTTPS support for your bucket, upload your own security certificate to Object Storage. For more information, see Bucket naming rules.
If you don't have Terraform, install it and configure the Yandex Cloud provider.
-
In the configuration file, describe the parameters of the resources you want to create:
terraform { required_providers { yandex = { source = "yandex-cloud/yandex" } } required_version = ">= 0.13" } provider "yandex" { token = "<IAM_or_OAuth_token>" cloud_id = "<cloud_ID>" folder_id = "<folder_ID>" zone = "ru-central1-a" } resource "yandex_iam_service_account" "sa" { name = "<service_account_name>" } // Assigning roles to the service account resource "yandex_resourcemanager_folder_iam_member" "sa-editor" { folder_id = "<folder_ID>" role = "storage.editor" member = "serviceAccount:${yandex_iam_service_account.sa.id}" } // Creating a static access key resource "yandex_iam_service_account_static_access_key" "sa-static-key" { service_account_id = yandex_iam_service_account.sa.id description = "static access key for object storage" } // Creating a bucket using the key resource "yandex_storage_bucket" "test" { access_key = yandex_iam_service_account_static_access_key.sa-static-key.access_key secret_key = yandex_iam_service_account_static_access_key.sa-static-key.secret_key bucket = "<bucket_name>" }
Where:
yandex_iam_service_account
: Description of the service account that will create and use a bucket:name
: Service account name
yandex_storage_bucket
: Bucket description:bucket
: Bucket name
For more information about resources you can create using Terraform, see the provider documentation
. -
Make sure the configuration files are correct.
- In the command line, go to the directory where you created the configuration file.
- Run a check using this command:
terraform plan
If the configuration is described correctly, the terminal will display a list of created resources and their parameters. If the configuration contains any errors, Terraform will point them out.
-
Deploy cloud resources.
-
If the configuration does not contain any errors, run this command:
terraform apply
-
Confirm that you want to create the resources.
All the resources you need will then be created in the specified folder. You can check the new resources and their configuration using the management console
. -
To create a bucket, use the create REST API method for the Bucket resource, the BucketService/Create gRPC API call, or the create S3 API method.