Skip to content

Instantly share code, notes, and snippets.

@kaxil
Created March 27, 2020 18:41
Show Gist options
  • Save kaxil/4eadd89d2d00cc17a055bd04e1192799 to your computer and use it in GitHub Desktop.
Save kaxil/4eadd89d2d00cc17a055bd04e1192799 to your computer and use it in GitHub Desktop.
Example DAG to test Airflow-Vault Integration
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from datetime import datetime
from airflow.hooks.base_hook import BaseHook
def get_secrets(**kwargs):
conn = BaseHook.get_connection(kwargs['my_conn_id'])
print(f"Password: {conn.password}, Login: {conn.login}, URI: {conn.get_uri()}, Host: {conn.host}")
with DAG('example_secrets_dags', start_date=datetime(2020, 1, 1), schedule_interval=None) as dag:
test_task = PythonOperator(
task_id='test-task',
python_callable=get_secrets,
op_kwargs={'my_conn_id': 'smtp_default'},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment