airflow-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Phillips <andr...@apache.org>
Subject Re: programatically configure aws_default, emr_default connections?
Date Mon, 16 Oct 2017 22:04:27 GMT
> Is there any way to programatically configure the aws_default,
> emr_default or other airflow connections?

In a pre-1.8.x installation we used the following script:

--- snip ---
#!/usr/bin/python

import json

from airflow import models
from airflow.utils import db as db_utils

CONNECTIONS = [
     models.Connection(
         conn_id='foo', conn_type='http',
         host='...', port='8080'),
     models.Connection(
         conn_id='bar', conn_type='ssh',
         host='...'),
     models.Connection(
         conn_id='baz', conn_type='http',
         host='...', port='7099'),
     models.Connection(
         conn_id='sqs_us_east_1', conn_type='s3',
         extra=json.dumps({ 'region': 'us-east-1' }))
]

for connection in CONNECTIONS:
     print "Adding connection {}".format(connection.conn_id)
     db_utils.merge_conn(connection)
--- snip ---

This was for adding *new* connections, but I would suspect that this or 
similar code could also be used to modify existing connections.

There may well be a better approach for Airflow 1.8.x, though.

Regards

ap

Mime
View raw message