Configuring access permissions for a bucket using Identity and Access Management
Object Storage incorporates several access management mechanisms. To learn how these mechanisms interact, see Access management methods in Object Storage: Overview.
To configure access to a bucket using Identity and Access Management, assign a user, user group, or service account a role for that bucket:
- In the management console
, select a folder. - Go to Object Storage.
- Click the name of the bucket you want to grant access to.
- In the left-hand menu, select Security.
- Navigate to the Access bindings tab.
- Click Assign roles.
- Select a user from the list or use the user search option.
- Click Add role.
- Select a role for the user.
- Click Save.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To assign a role for a bucket using Terraform:
-
In the Terraform configuration file, describe the resources you want to create:
resource "yandex_storage_bucket_iam_binding" "mybucket-viewers" { bucket = "<bucket_name>" role = "<role>" members = [ "<subject_type>:<subject_ID>", "serviceAccount:<service_account_ID>", "userAccount:<user_ID>" ] } # Example of assigning the `storage.editor` role to service accounts resource "yandex_storage_bucket_iam_binding" "sa-editors" { bucket = "<bucket_name>" role = "storage.editor" members = [ "serviceAccount:<service_account_1_ID>", "serviceAccount:<service_account_2_ID>" ] } # Example of assigning the `storage.admin` role to users resource "yandex_storage_bucket_iam_binding" "users-admins" { bucket = "<bucket_name>" role = "storage.admin" members = [ "userAccount:<user_1_ID>", "userAccount:<user_2_ID>" ] }Where:
-
bucket: Bucket name. -
role: Role.Warning
You cannot use the yandex_storage_bucket_iam_binding resource to assign primitive roles, such as
viewer,editor, oradminfor a bucket if the yandex_storage_bucket_grant resource or theaclorgrantparameters of the yandex_storage_bucket resource are used simultaneously. -
members: Types and IDs of entities assigned the role. Specify it asuserAccount:<user_ID>orserviceAccount:<service_account_ID>.
For more information about
yandex_storage_bucket_iam_bindingresource properties, see this provider guide. -
-
If you intend to use the yandex_storage_bucket_iam_binding resource together with yandex_storage_bucket_grant for the same bucket, we recommend creating them sequentially. To do this, add a dependency on the
yandex_storage_bucket_grantresource to theyandex_storage_bucket_iam_bindingsection.resource "yandex_storage_bucket_iam_binding" "mybucket-viewers" { ... depends_on = [ yandex_storage_bucket_grant.my_bucket_grant ] } -
Apply the configuration:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
You can check the resource update using the management console
. -
Use the updateAccessBindings REST API method for the Bucket resource or the BucketService/UpdateAccessBindings gRPC API call.
You can also assign a role for a bucket in Identity and Access Management.