Creating a bucket
The minimum role required to create a bucket is storage.editor
. See the role description.
- 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 the bucket name, following the naming guidelines.
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.
-
If necessary, limit the maximum bucket size.
If
0
, the maximum size isn't limited. It's similar to the enabled No limit option. -
Selected the type of access.
-
Select the default storage class.
-
Click Create bucket to complete the operation.
-
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
In the configuration file, describe the parameters of resources that you want to create:
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
is the 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 that the configuration files are correct.
- In the command line, go to the directory where you created the configuration file.
- Run the check using the command:
terraform plan
If the configuration is described correctly, the terminal displays a list of created resources and their parameters. If the configuration contain errors, Terraform will point them out.
-
Deploy the cloud resources.
-
If the configuration doesn't contain any errors, run the command:
terraform apply
-
Confirm that you want to create the resources.
Afterwards, all the necessary resources are created in the specified folder. You can check that the resources are there with the correct settings using the management console.
-