[Yandex Cloud documentation](../../../index.md) > [Yandex Identity and Access Management](../../index.md) > [Step-by-step guides](../index.md) > Service accounts > Updating a service account

# Updating a service account

You can change a service account's name and description. Using the Yandex Cloud API you can also [label](../../../resource-manager/concepts/labels.md) a service account.

To change a service account's roles, follow [this guide](assign-role-for-sa.md).

{% list tabs group=instructions %}

- Management console {#console}

  To update a service account:

  1. In the [management console](https://console.yandex.cloud), click ![image](../../../_assets/console-icons/layout-side-content-left.svg) or ![image](../../../_assets/console-icons/chevron-down.svg) in the top panel and select the folder the service account belongs to.
  1. In the list of services, select **Identity and Access Management**.
  1. In the left-hand panel, select ![FaceRobot](../../../_assets/console-icons/face-robot.svg) **Service accounts**.
  1. In the row with the service account you need, click ![image](../../../_assets/console-icons/ellipsis.svg) and select **Edit **.
  1. Change the name of your service account.

     The naming requirements are as follows:
      
     * Length: between 3 and 63 characters.
     * It can only contain lowercase Latin letters, numbers, and hyphens.
     * It must start with a letter and cannot end with a hyphen.

  1. Change the description of your service account.
  1. Click **Save**.

- CLI {#cli}

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

  To update a service account:

  1. See the description of the update service account command:

      ```bash
      yc iam service-account update --help
      ```

  1. Select a service account, e.g., `my-robot`:

      ```bash
      yc iam service-account list
      ```
      
      Result:

      ```text
      +----------------------+------------------+-------------------------------+
      |          ID          |       NAME       |          DESCRIPTION          |
      +----------------------+------------------+-------------------------------+
      | aje6o61dvog2******** | my-robot         |                               |
      | aje9sda1ufvq******** | account_name     | account_description           |
      +----------------------+------------------+-------------------------------+
      ```

  1. Change the service account parameters, such as name and description:

      ```bash
      yc iam service-account update my-robot \
        --new-name my-service-account \
        --description "this is my service account"
      ```
      
      The naming requirements are as follows:
      
      * Length: between 3 and 63 characters.
      * It can only contain lowercase Latin letters, numbers, and hyphens.
      * It must start with a letter and cannot end with a hyphen.

- Terraform {#tf}

  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 update a service account:

  1. Open the Terraform configuration file and edit the fragment with the service account description.
     Example of the service account description in the Terraform configuration:

     ```hcl
     ...
     resource "yandex_iam_service_account" "sa" {
       name        = "my-robot"
       description = "this is new description"
      }
     ...
     ```
  1. Check the configuration using this command:
     ```bash
     terraform validate
     ```
     
     If the configuration is correct, you will get this message:
     
     ```text
     Success! The configuration is valid.
     ```

  1. Run this command:
     ```bash
     terraform plan
     ```
  
     You will see a detailed list of resources. No changes will be made at this step. Terraform will show any errors in the configuration.

  1. Apply the changes:
     ```bash
     terraform apply
     ```
     
  1. Confirm the changes: type `yes` into the terminal and press **Enter**.

     You can check whether the service account has been updated in the [management console](https://console.yandex.cloud) or using the [CLI](../../../cli/quickstart.md) command:

     ```bash
     yc iam service-account list
     ```

- API {#api}

  To update a service account, use the [update](../../api-ref/ServiceAccount/update.md) REST API method for the [ServiceAccount](../../api-ref/ServiceAccount/index.md) resource or the [ServiceAccountService/Update](../../api-ref/grpc/ServiceAccount/update.md) gRPC API call.

{% endlist %}