Getting the service account ID
If you do not have a service account, create one.
- In the management console
, select the folder the service account belongs to. - At the top of the screen, go to the Service accounts tab.
- Choose a service account and click the row with its name.
- The Overview page will show the service account ID as a string in the
aje9sb6ffd2u********
format.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
If you know the service account name, use the get
command to get the account ID:
yc iam service-account get my-robot
Result:
id: aje6o61dvog2********
...
If you don't know the name, get a list of service accounts in the default folder:
yc iam service-account list
Result:
+----------------------+------------------+-------------------------------+
| ID | NAME | DESCRIPTION |
+----------------------+------------------+-------------------------------+
| aje6o61dvog2******** | my-robot | |
| aje9sda1ufvq******** | account_name | account_description |
+----------------------+------------------+-------------------------------+
-
Find out the ID of the folder where the service account was created.
-
Get information about the service accounts in the folder using the list REST API method for the ServiceAccount resource:
export FOLDER_ID=b1gvmob95yys******** export IAM_TOKEN=CggaATEVAgA... curl -H "Authorization: Bearer ${IAM_TOKEN}" \ "https://iam.api.cloud.yandex.net/iam/v1/serviceAccounts?folderId=${FOLDER_ID}" { "serviceAccounts": [ { "id": "ajebqtreob2d********", "folderId": "b1gvmob95yys********", "createdAt": "2018-10-18T13:42:40Z", "name": "my-robot", "description": "my description" } ] }
You can also get information about the service accounts in the folder using the ServiceAccountService/List gRPC API call.