11Running this sample with the managed YDB instance in Yandex Cloud
2- *********************************************************************************
2+ ---
33
44(0) Install the yc command line tool
55https://cloud.yandex.ru/docs/cli/operations/install-cli
66
77(1) Create the service account using the YC Web Console, and assign it the ydb.editor role.
88Alternatively use the following shell snippet:
99
10+ ``` bash
1011# Specify the Yandex Cloud folder and service account name
1112export YC_FOLDER=mzinal
1213export SA_NAME=ydb-sa-0
@@ -16,24 +17,33 @@ yc iam service-account create $SA_NAME
1617export SA_ID=` yc iam service-account get --name $SA_NAME | sed -n ' s/^id: \(.*\)$/\1/p' `
1718# Assign the ydb.editor role for the specified YC folder to the service account just created
1819yc resource-manager folder add-access-binding $YC_FOLDER --role ydb.editor --subject serviceAccount:$SA_ID
20+ ```
1921
2022(2) Generate the service account key to be used for authentication.
2123Note: unfortunately, right now YC Web Console does not offer a way to generate the SA key
2224with its Web interface.
2325
26+ ``` bash
2427yc iam key create --service-account-name $SA_NAME --output $HOME /key-ydb-sa-0.json
28+ ```
2529
2630(3) Obtain the endpoint and database path from the Web Console.
27- Alternatively, use the following command to grab it in the shell:
31+ Alternatively, use the following command to grab the required data in the shell:
2832
29- yc ydb db get --name ydb406
33+ ``` bash
34+ yc ydb db get --name ydb1
35+ ```
36+
37+ ` ydb1 ` value in the command above is the logical name of the YDB managed database.
3038
3139(4) Run the sample:
3240
41+ ``` bash
3342# Set the path to the service account key file
3443export YDB_SERVICE_ACCOUNT_KEY_FILE_CREDENTIALS=$HOME /key-ydb-sa-0.json
3544# Set the database path and its endpoint
3645export YDB_ENDPOINT=grpcs://ydb.serverless.yandexcloud.net:2135
3746export YDB_DATABASE=/ru-central1/b1gfvslmokutuvt2g019/etnvbffeqegu1ub2rg2o
3847# Run the script
3948python3 __main__.py -e $YDB_ENDPOINT -d $YDB_DATABASE
49+ ```
0 commit comments