Creating and updating profiles

Currently you can only create and update profiles interactively using the following commands:

  1. ydb init

Creating a profile - 图1

or

  1. ydb config profile create [profile_name]

Creating a profile - 图2

where [profile_name] is an optional name of the profile being created or updated.

The first step of the interactive scenario is different in the init and profile create commands:

Init

Profile Create

Outputs a list of existing profiles (if any) and prompts you to make a choice: Create a new or update the configuration of an existing profile:

  1. Please choose profile to configure:
  2. [1] Create a new profile
  3. [2] test
  4. [3] local

Creating a profile - 图3

If no profiles exist or you select option 1 in the previous step, the name of a profile to create is requested:

  1. Please enter name for a new profile:

Creating a profile - 图4

If you enter the name of an existing profile at this point, the YDB CLI proceeds to updating its parameters as if an option with the name of this profile was selected at once.

If no profile name is specified in the command line, it is requested:

  1. Please enter configuration profile name to create or re-configure:

Creating a profile - 图5

Next, you’ll be prompted to sequentially perform the following actions with each connection parameter that can be saved in the profile:

  • Don’t save
  • Set a new value or Use - Set a new value or Use
  • Use current value (this option is available when updating an existing profile)

Example

Creating a new mydb1 profile:

  1. Run the command:

    1. ydb config profile create mydb1

    Creating a profile - 图6

  2. Specify the endpoint or don’t save this parameter for the profile:

    1. Pick desired action to configure endpoint:
    2. [1] Set a new endpoint value
    3. [2] Don't save endpoint for profile "mydb1"
    4. Please enter your numeric choice:

    Creating a profile - 图7

  3. Enter the DB name or don’t save this parameter for the profile:

    1. Pick desired action to configure database:
    2. [1] Set a new database value
    3. [2] Don't save database for profile "mydb1"
    4. Please enter your numeric choice:

    Creating a profile - 图8

  4. Select the authentication mode or don’t save this parameter for the profile:

    1. Pick desired action to configure authentication method:
    2. [1] Use IAM token (iam-token) cloud.yandex.com/docs/iam/concepts/authorization/iam-token
    3. [2] Use OAuth token of a Yandex Passport user (yc-token) cloud.yandex.com/docs/iam/concepts/authorization/oauth-token
    4. [3] Use metadata service on a virtual machine (use-metadata-credentials) cloud.yandex.com/docs/compute/operations/vm-connect/auth-inside-vm
    5. [4] Use security account key file (sa-key-file) cloud.yandex.com/docs/iam/operations/iam-token/create-for-sa
    6. [5] Don't save authentication data for profile "mydb1"
    7. Please enter your numeric choice:

    Creating a profile - 图9

    If you are not sure what authentication mode to choose, see the Authentication article in the “Getting started” section.

    All available authentication methods are described in Connecting to and authenticating with a database. The set of methods and text of the hints may differ from those given in this example.

    If the method you choose involves specifying an additional parameter, you’ll be prompted to enter it. For example, if you select 4 (Use service account key file):

    1. Please enter Path to service account key file (sa-key-file):

    Creating a profile - 图10

  5. In the last step, you’ll be prompted to activate the created profile to be used by default. Choose ‘n’ (No) until you read the article about Activating a profile and using the activated profile:

    1. Activate profile "mydb1" to use by default? (current active profile is not set) y/n: n

    Creating a profile - 图11