[Yandex Cloud documentation](../../../index.md) > [Yandex Object Storage](../../index.md) > [Step-by-step guides](../index.md) > Buckets > Configuring access permissions using IAM

# 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](../../security/overview.md).

To configure access to a [bucket](../../concepts/bucket.md) using [Identity and Access Management](../../security/index.md), assign a user, user group, or service account a [role](../../security/index.md#roles-list) for that bucket:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select a folder.
  1. Navigate to **Object Storage**.
  1. Click the name of the bucket you want to grant access to.
  1. In the left-hand menu, select **Security**.
  1. Navigate to the **Access bindings** tab.
  1. Click **Assign roles**.
  1. Select a user from the list or use the user search option.
  1. Click **Add role**.
  1. Select a role for the user.
  1. Click **Save**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  1. See the description of the CLI command for updating bucket settings:

      ```bash
      yc storage bucket update --help
      ```

  1. Assign a role for the bucket:

      ```bash
      yc storage bucket update \
        --name <bucket_name> \
        --grants grantee-id=<account_ID>,grant-type=<subject_type>,permission=<permission>
      ```

      Where: 
      * `--name`: Bucket name.
      * `--grants`: [ACL](../../concepts/acl.md) access permission settings:
        * `grantee-id`: ID of the account the permissions are granted to. Used when the value is `grant-type=grant-type-account`.
        * `grant-type`: Type of entity the permissions are granted to. The possible values are:
          * `grant-type-account`: User or service account.
          * `grant-type-all-authenticated-users`: All authenticated users.
          * `grant-type-all-users`: All users.
        * `permission`: Permission. The possible values are:
          * `permission-full-control`: Full access to the bucket and objects in it.
          * `permission-write`: Writing objects to the bucket.
          * `permission-write-acp`: Editing bucket ACL.
          * `permission-read`: Reading objects in the bucket.
          * `permission-read-acp`: Reading bucket ACL.
  
  If the `yc storage bucket update` command is called, the bucket's assigned ACL roles are overwritten, not appended. To preserve existing permissions settings, they must be re-listed in the `--grants` parameter.

  Learn more about the `yc storage bucket update` command in the [YC CLI reference](../../cli-ref/bucket/update.md).
  
  ## Example {#example}

  To assign a service account full access to a bucket using the CLI:

  1. Get a list of buckets in the default folder:

      ```bash
      yc storage bucket list
      ```
 
      Result:
 
      ```text
      +------------------+----------------------+----------+-----------------------+---------------------+
      |       NAME       |      FOLDER ID       | MAX SIZE | DEFAULT STORAGE CLASS |     CREATED AT      |
      +------------------+----------------------+----------+-----------------------+---------------------+
      | my-bucket        | b1gmit33ngp3******** | 10       | STANDARD              | 2022-12-16 13:58:18 |
      +------------------+----------------------+----------+-----------------------+---------------------+
      ```

  1. Get a list of service accounts in the default folder:

      ```bash
      yc iam service-account list
      ```
 
      Result:
 
      ```text
      +----------------------+--------------+--------+---------------------+-----------------------+
      |          ID          |     NAME     | LABELS |     CREATED AT      | LAST AUTHENTICATED AT |
      +----------------------+--------------+--------+---------------------+-----------------------+
      | ajeg2b2et02f******** | my-robot     |        | 2024-09-08 18:59:45 | 2025-02-18 10:10:00   |
      | ajegtlf2q28a******** | account-name |        | 2023-06-27 16:18:18 | 2025-02-18 10:20:00   |
      +----------------------+--------------+--------+---------------------+-----------------------+
      ```

  1. Assign a role for the bucket:

      ```bash
      yc storage bucket update \
        --name my-bucket \
        --grants grantee-id=ajeg2b2et02f********,grant-type=grant-type-account,permission=permission-full-control
      ```

  Result:
      
  ```text
  name: my-bucket
  folder_id: b1g0ijbfaqsn********
  default_storage_class: STANDARD
  versioning: VERSIONING_DISABLED
  max_size: "53687091200"
  acl:
    grants:
      - permission: PERMISSION_FULL_CONTROL
        grant_type: GRANT_TYPE_ACCOUNT
        grantee_id: ajeg2b2et02f********
  created_at: "2026-04-30T09:48:38.836171Z"
  resource_id: e3ev6mif5rb1********
  ```

- Terraform {#tf}

  With [Terraform](https://www.terraform.io/), you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
  
  Terraform is distributed under the [Business Source License](https://github.com/hashicorp/terraform/blob/main/LICENSE). The [Yandex Cloud provider for Terraform](https://github.com/yandex-cloud/terraform-provider-yandex) is distributed under the [MPL-2.0](https://www.mozilla.org/en-US/MPL/2.0/) license.
  
  For more information about the provider resources, see the relevant documentation on the [Terraform](https://www.terraform.io/docs/providers/yandex/index.html) website or [its mirror](../../../terraform/index.md).

  If you do not have Terraform yet, [install it and configure the Yandex Cloud provider](../../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
  
  
  To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), [authenticate](../../../terraform/authentication.md) using the appropriate method.

  To assign a role for a bucket using Terraform:

  1. In the Terraform configuration file, describe the resources you want to create:

      ```hcl
      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](../../security/index.md#roles-list) to assign.

        {% note warning %}
        
        You cannot use the [yandex_storage_bucket_iam_binding](../../../terraform/resources/storage_bucket_iam_binding.md) resource to assign [primitive roles](../../security/index.md#primitive-roles), such as `viewer`, `editor`, or `admin` for a bucket if the [yandex_storage_bucket_grant](../../../terraform/resources/storage_bucket_grant.md) resource or the `acl` or `grant` parameters of the [yandex_storage_bucket](../../../terraform/resources/storage_bucket.md) resource are used simultaneously.
        
        {% endnote %}

      * `members`: Types and IDs of [entities](../../../iam/concepts/access-control/index.md#subject) getting the role. Specify it as `userAccount:<user_ID>` or `serviceAccount:<service_account_ID>`.

      For more information about the `yandex_storage_bucket_iam_binding` resource properties, see [this provider guide](../../../terraform/resources/storage_bucket_iam_binding.md).

  1. If you intend to use the [yandex_storage_bucket_iam_binding](../../../terraform/resources/storage_bucket_iam_binding.md) resource together with [yandex_storage_bucket_grant](../../../terraform/resources/storage_bucket_grant.md) for the same bucket, we recommend creating them sequentially. To do this, add a dependency on the `yandex_storage_bucket_grant` resource to the `yandex_storage_bucket_iam_binding` section.

      ```hcl
      resource "yandex_storage_bucket_iam_binding" "mybucket-viewers" {
        ...
      
        depends_on = [
          yandex_storage_bucket_grant.my_bucket_grant
        ]
      }
      ```

  1. Apply the configuration:

      1. In the terminal, navigate to the configuration file directory.
      1. Make sure the configuration is correct using this command:
      
         ```bash
         terraform validate
         ```
      
         If the configuration is valid, you will get this message:
      
         ```bash
         Success! The configuration is valid.
         ```
      
      1. Run this command:
      
         ```bash
         terraform plan
         ```
      
         You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
      1. Apply the configuration changes:
      
         ```bash
         terraform apply
         ```
      
      1. Type `yes` and press **Enter** to confirm the changes.

      You can check the resource update using the [management console](https://console.yandex.cloud).

- API {#api}

  Use the [updateAccessBindings](../../api-ref/Bucket/updateAccessBindings.md) REST API method for the [Bucket](../../api-ref/Bucket/index.md) resource or the [BucketService/UpdateAccessBindings](../../api-ref/grpc/Bucket/updateAccessBindings.md) gRPC API call.

{% endlist %}

You can also [assign](../../../iam/operations/roles/grant.md) a role for a bucket in Identity and Access Management.