Updating a service account
You can change a service account's name and description. Using the Yandex Cloud API you can also label a service account.
To change a service account's roles, follow this guide.
To update a service account:
-
In the management console
, navigate to the folder the service account belongs to. -
In the list of services, select Identity and Access Management.
-
In the left-hand panel, select
Service accounts. -
In the line with the service account you need, click
and select **Edit **. -
Change the name of your service account.
The name format requirements are as follows:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
Change the description of your service account.
-
Click Save.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
To update a service account:
-
See the description of the update service account command:
yc iam service-account update --help
-
Select a service account, e.g.,
my-robot
:yc iam service-account list
Result:
+----------------------+------------------+-------------------------------+ | ID | NAME | DESCRIPTION | +----------------------+------------------+-------------------------------+ | aje6o61dvog2******** | my-robot | | | aje9sda1ufvq******** | account_name | account_description | +----------------------+------------------+-------------------------------+
-
Change the service account parameters, such as name and description:
yc iam service-account update my-robot \ --new-name my-service-account \ --description "this is my service account"
The name format requirements are as follows:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
If you don't have Terraform, install it and configure the Yandex Cloud provider.
To update a service account:
-
Open the Terraform configuration file and edit the fragment with the service account description.
Example of the service account description in the Terraform configuration:... resource "yandex_iam_service_account" "sa" { name = "my-robot" description = "this is new description" } ...
-
Check the configuration using this command:
terraform validate
If the configuration is correct, you will get this message:
Success! The configuration is valid.
-
Run this command:
terraform plan
The terminal will display a list of resources with parameters. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
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
or using the CLI command:yc iam service-account list
To update a service account, use the update REST API method for the ServiceAccount resource or the ServiceAccountService/Update gRPC API call.