airflow.providers.yandex.secrets.lockbox¶
與從 Yandex Cloud Lockbox 獲取金鑰相關的物件。
類¶
從 Yandex Lockbox 檢索連線、變數或配置。 |
模組內容¶
- class airflow.providers.yandex.secrets.lockbox.LockboxSecretBackend(yc_oauth_token=None, yc_sa_key_json=None, yc_sa_key_json_path=None, yc_connection_id=None, folder_id='', connections_prefix='airflow/connections', variables_prefix='airflow/variables', config_prefix='airflow/config', sep='/', endpoint=None)[source]¶
基類:
airflow.secrets.BaseSecretsBackend,airflow.utils.log.logging_mixin.LoggingMixin從 Yandex Lockbox 檢索連線、變數或配置。
可透過
airflow.cfg進行如下配置:[secrets] backend = airflow.providers.yandex.secrets.lockbox.LockboxSecretBackend backend_kwargs = {"connections_prefix": "airflow/connections"}
例如,當設定
{"connections_prefix": "airflow/connections"}時,如果金鑰使用路徑airflow/connections/smtp_default定義,則可以使用 conn_id 為smtp_default的連線。當設定
{"variables_prefix": "airflow/variables"}時,如果金鑰使用路徑airflow/variables/hello定義,則可以使用名稱為hello的變數。當設定
{"config_prefix": "airflow/config"}時,如果金鑰使用路徑airflow/config/sql_alchemy_conn定義,則可以使用 key 為sql_alchemy_conn的配置。如果字首為空,則不會向 Yandex Lockbox 傳送請求。
[secrets] backend = airflow.providers.yandex.secrets.lockbox.LockboxSecretBackend backend_kwargs = {"yc_connection_id": "<connection_ID>", "folder_id": "<folder_ID>"}
您需要指定憑據或
yandexcloud連線的 ID 以連線到 Yandex Lockbox。憑據將按以下優先順序使用:OAuth 令牌
檔案中的 JSON 格式服務賬號金鑰
JSON 格式服務賬號金鑰
Yandex Cloud 連線
如果您未指定任何憑據,系統將使用預設連線 ID:
yandexcloud_default。此外,您還需要指定 Yandex Cloud 資料夾 ID,以便在其中搜索 Yandex Lockbox 金鑰。如果您未指定資料夾 ID,則請求將使用連線的
folder_id(如果已指定)。- 引數:
yc_oauth_token (str | None) – 指定用於連線到 Yandex Lockbox 的使用者賬號 OAuth 令牌。引數值應類似於
y3_xx123。yc_sa_key_json (dict | str | None) – 指定 JSON 格式的服務賬號金鑰。引數值應類似於
{"id": "...", "service_account_id": "...", "private_key": "..."}。yc_sa_key_json_path (str | None) – 指定 JSON 格式服務賬號金鑰檔案的路徑。引數值應類似於
/home/airflow/authorized_key.json,檔案內容應採用以下格式:{"id": "...", "service_account_id": "...", "private_key": "..."}。yc_connection_id (str | None) – 指定用於連線到 Yandex Lockbox 的連線 ID。預設值為
yandexcloud_default。folder_id (str) – 指定用於在其中搜索 Yandex Lockbox 金鑰的資料夾 ID。如果設定為
None(在 JSON 中為null),則請求將使用連線的folder_id(如果已指定)。connections_prefix (str | None) – 指定讀取金鑰以獲取連線的字首。如果設定為
None(在 JSON 中為null),則不會向 Yandex Lockbox 傳送連線請求。預設值為airflow/connections。variables_prefix (str | None) – 指定讀取金鑰以獲取變數的字首。如果設定為
None(在 JSON 中為null),則不會向 Yandex Lockbox 傳送變數請求。預設值為airflow/variables。config_prefix (str | None) – 指定讀取金鑰以獲取配置的字首。如果設定為
None(在 JSON 中為null),則不會向 Yandex Lockbox 傳送變數請求。預設值為airflow/config。sep (str) – 指定用於連線
secret_prefix和secret_id的分隔符。預設值為/。endpoint (str | None) – 指定 API 端點。如果設定為
None(在 JSON 中為null),則請求將使用連線的端點(如果已指定);否則,將使用預設端點。