Skip to main content
You can perform operations on behalf of a service account without creating authorized keys for it. To do this, impersonate the service account with your user account credentials. When you impersonate a service account, IAM exchanges your user account’s access token for an access token of the service account. Operations that you perform with this token are performed by the service account, and IAM checks the permissions of the service account. For example, if the service account is only in a group with the viewer role, you can read resources but not create or modify them, even if you are an administrator. Impersonation is useful when you want to:
  • Run commands or Terraform configurations as a service account without storing its credentials.
  • Check which operations a service account can perform with its current group memberships.

Prerequisites

  1. Install and configure the Nebius AI Cloud CLI.
  2. Create a service account if you haven’t already.
  3. Add the service account to a group that grants it the required permissions.

How to impersonate a service account

To run a Nebius AI Cloud CLI command as the service account, add the --impersonate-service-account-id (or -I as a short version) parameter to the command. You can add it to any command.To run all commands of a CLI profile as the service account, add the impersonate-service-account-id key to the profile in the ~/.nebius/config.yaml file:
To check that impersonation works:
  1. List service accounts in your project and copy the ID of the service account (metadata.id) to impersonate:
  2. Check that the command uses the identity of the service account:
    In this command, <service_account_ID> is the metadata.id value that you copied in the previous step. The service_account_profile.info.metadata.id in the output should match the ID of the service account.
To get an access token of the service account, for example, to use it in API requests or other tools, run:
For more information about access tokens, see Access tokens in Nebius AI Cloud.

See also