I am trying to create a composer environment with the approach of infrastructure as code. For this, I need to store and retrieve airflow variables programmatically and keep them versioned somewhere.
In a previous post, Ed Morton wrote a script to convert the table to a JSON, but there is a problem related to the way composer/airflow outputs the data when using the following command :
gcloud composer environments run `$COMPOSER_ENV` --location <location> connections -- --list
A sample of the output is :
╒════════════════════════════════╤═════════════════════════════╤════════════════════════════════╤════════╤════════════════╤══════════════════════╤════════════════════════════════╕
│ Conn Id │ Conn Type │ Host │ Port │ Is Encrypted │ Is Extra Encrypted │ Extra │
╞════════════════════════════════╪═════════════════════════════╪════════════════════════════════╪════════╪════════════════╪══════════════════════╪════════════════════════════════╡
│ 'airflow_db' │ 'mysql' │ 'airflow-sqlp...rvice.default' │ None │ True │ False │ None │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
As you can see, the problem is the Host, and Extra columns contain an ellipsis ... that abridges long text such as here 'airflow-sqlp...rvice.default'.
How do I get a full version of the information output by the above-mentioned (composer) utility?
I am using composer-1.12.1-airflow-1.10.9. Unfortunately the nice feature of exporting the connections to a JSON using the CLI is only available in the latest version of airflow.