You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/howto/use-alternative-secrets-backend.rst
+86-23Lines changed: 86 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -383,48 +383,76 @@ Note that the secret ``Key`` is ``value``, and secret ``Value`` is ``world`` and
383
383
384
384
.. _secret_manager_backend:
385
385
386
-
GCP Secret Manager Backend
387
-
^^^^^^^^^^^^^^^^^^^^^^^^^^
386
+
Google Cloud Secret Manager Backend
387
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
388
388
389
-
To enable GCP Secrets Manager to retrieve connection/variables, specify :py:class:`~airflow.providers.google.cloud.secrets.secret_manager.CloudSecretManagerBackend`
390
-
as the ``backend`` in ``[secrets]`` section of ``airflow.cfg``.
389
+
This topic describes how to configure Airflow to use `Secret Manager <https://cloud.google.com/secret-manager/docs>`__ as
390
+
a secret backend and how to manage secrets.
391
391
392
-
Available parameters to ``backend_kwargs``:
392
+
Before you begin
393
+
""""""""""""""""
393
394
394
-
* ``connections_prefix``: Specifies the prefix of the secret to read to get Connections.
395
-
* ``variables_prefix``: Specifies the prefix of the secret to read to get Variables.
396
-
* ``gcp_key_path``: Path to GCP Credential JSON file
* ``sep``: separator used to concatenate connections_prefix and conn_id. Default: "-"
395
+
`Configure Secret Manager and your local environment <https://cloud.google.com/secret-manager/docs/configuring-secret-manager>`__, once per project.
399
396
400
-
Note: The full GCP Secrets Manager secret id should follow the pattern "[a-zA-Z0-9-_]".
397
+
Enabling the secret backend
398
+
"""""""""""""""""""""""""""
401
399
402
-
Here is a sample configuration if you want to just retrieve connections:
400
+
To enable the secret backend for Google Cloud Secrets Manager to retrieve connection/variables,
* ``sep``: Separator used to concatenate connections_prefix and conn_id. Default: "-"
436
+
* ``project_id``: Project ID to read the secrets from. If not passed, the project ID from credentials will be used.
437
+
438
+
All options should be passed as a JSON dictionary.
439
+
440
+
For example, if you want to set parameter ``connections_prefix`` to ``"airflow-tenant-primary"`` and parameter ``variables_prefix`` to ``"variables_prefix"``, your configuration file should look like this:
When ``gcp_key_path`` is not provided, it will use the Application Default Credentials (ADC) to obtain credentials.
453
+
* By default, Application Default Credentials (ADC) is used obtain credentials.
454
+
* ``gcp_key_path`` option in ``backend_kwargs`` option - allows you to configure authorizations with a service account stored in local file.
455
+
* ``gcp_keyfile_dict`` option in ``backend_kwargs`` option - allows you to configure authorizations with a service account stored in Airflow configuration.
428
456
429
457
.. note::
430
458
@@ -433,8 +461,43 @@ When ``gcp_key_path`` is not provided, it will use the Application Default Crede
* `Setting Up Authentication for Server to Server Production Applications <https://cloud.google.com/docs/authentication/production>`__
435
463
436
-
The value of the Secrets Manager secret id must be the :ref:`connection URI representation <generating_connection_uri>`
437
-
of the connection object.
464
+
Managing secrets
465
+
""""""""""""""""
466
+
467
+
If you want to configure a connection, you need to save it as a :ref:`connection URI representation <generating_connection_uri>`.
468
+
Variables should be saved as plain text.
469
+
470
+
In order to manage secrets, you can use the ``gcloud`` tool or other supported tools. For more information, take a look at:
471
+
`Managing secrets <https://cloud.google.com/secret-manager/docs/creating-and-accessing-secrets>`__ in Google Cloud Documentation.
472
+
473
+
The name of the secret must fit the following formats:
474
+
475
+
* for variable: ``[connections_prefix][sep][variable_name]``
476
+
* for connection: ``[variable_prefix][sep][connection_name]``
477
+
478
+
where:
479
+
480
+
* ``connections_prefix`` - fixed value defined in the ``connections_prefix`` parameter in backend configuration. Default: ``airflow-connections``.
481
+
* ``variable_prefix`` - fixed value defined in the ``variable_prefix`` parameter in backend configuration. Default: ``airflow-variables``.
482
+
* ``sep`` - fixed value defined in the ``sep`` parameter in backend configuration. Default: ``-``.
483
+
484
+
The Cloud Secrets Manager secret name should follow the pattern ``[a-zA-Z0-9-_]``.
485
+
486
+
If you have the default backend configuration and you want to create a connection with ``conn_id``
487
+
equals ``first-connection``, you should create secret named ``airflow-connections-first-connection``.
488
+
You can do it with the gcloud tools as in the example below.
0 commit comments