kaxil commented on a change in pull request #7741: [AIRFLOW-7076] Add support 
for HashiCorp Vault as Secrets Backend
URL: https://github.com/apache/airflow/pull/7741#discussion_r394019612
 
 

 ##########
 File path: docs/howto/use-alternative-secrets-backend.rst
 ##########
 @@ -0,0 +1,130 @@
+ .. Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+ ..   http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+
+Alternative secrets backend
+---------------------------
+
+In addition to retrieving connections from environment variables or the 
metastore database, you can enable
+an alternative secrets backend to retrieve connections,
+such as :ref:`AWS SSM Parameter Store <ssm_parameter_store_secrets>`,
+:ref:`Hashicorp Vault Secrets<hashicorp_vault_secrets>` or you can :ref:`roll 
your own <roll_your_own_secrets_backend>`.
+
+Search path
+^^^^^^^^^^^
+When looking up a connection, by default Airflow will search environment 
variables first and metastore
+database second.
+
+If you enable an alternative secrets backend, it will be searched first, 
followed by environment variables,
+then metastore.  This search ordering is not configurable.
+
+.. _secrets_backend_configuration:
+
+Configuration
+^^^^^^^^^^^^^
+
+The ``[secrets]`` section has the following options:
+
+.. code-block:: ini
+
+    [secrets]
+    backend =
+    backend_kwargs =
+
+Set ``backend`` to the fully qualified class name of the backend you want to 
enable.
+
+You can provide ``backend_kwargs`` with json and it will be passed as kwargs 
to the ``__init__`` method of
+your secrets backend.
+
+See :ref:`AWS SSM Parameter Store <ssm_parameter_store_secrets>` for an 
example configuration.
+
+.. _ssm_parameter_store_secrets:
+
+AWS SSM Parameter Store Secrets Backend
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+To enable SSM parameter store, specify 
:py:class:`~airflow.providers.amazon.aws.secrets.ssm.AwsSsmSecretsBackend`
+as the ``backend`` in  ``[secrets]`` section of ``airflow.cfg``.
+
+Here is a sample configuration:
+
+.. code-block:: ini
+
+    [secrets]
+    backend = airflow.providers.amazon.aws.secrets.ssm.AwsSsmSecretsBackend
+    backend_kwargs = {"prefix": "/airflow", "profile_name": "default"}
+
+If you have set your prefix as ``/airflow``, then for a connection id of 
``smtp_default``, you would want to
+store your connection at ``/airflow/AIRFLOW_CONN_SMTP_DEFAULT``.
+
+Optionally you can supply a profile name to reference aws profile, e.g. 
defined in ``~/.aws/config``.
+
+The value of the SSM parameter must be the :ref:`airflow connection URI 
representation <generating_connection_uri>` of the connection object.
+
+.. _hashicorp_vault_secrets:
+
+Hashicorp Vault Secrets Backend
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+To enable Hashicorp vault to retrieve connection, specify 
:py:class:`~airflow.providers.hashicorp.secrets.vault.VaultSecrets`
+as the ``backend`` in  ``[secrets]`` section of ``airflow.cfg``.
+
+Here is a sample configuration:
+
+.. code-block:: ini
+
+    [secrets]
+    backend = airflow.providers.hashicorp.secrets.vault.VaultSecrets
+    backend_kwargs = {"path": "airflow/connections", "url": 
"http://127.0.0.1:8200"}
+
+You can also set and pass values to Vault client by setting environment 
variables. All the
+environment variables listed at 
https://www.vaultproject.io/docs/commands/#environment-variables are supported.
+
+Hence, if you set ``VAULT_ADDR`` environment variable like below, you do not 
need to pass ``url``
+key to ``backend_kwargs``:
+
+.. code-block:: bash
+
+    export VAULT_ADDR="http://127.0.0.1:8200";
+
+If you have set your path as ``airflow/connections``, then for a connection id 
of ``smtp_default``, you would want to
+store your secret as:
+
+.. code-block:: bash
+
+    vault kv put secret/airflow/connections 
smtp_default=postgresql://airflow:airflow@host:5432/airflow
+
+The value of the Vault key must be the :ref:`airflow connection URI 
representation <generating_connection_uri>`
 
 Review comment:
   Updated

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to