forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for IAM database authentication for CloudSQL connection
- Loading branch information
1 parent
e20146d
commit 7944d78
Showing
3 changed files
with
519 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,3 +76,41 @@ Extra (optional) | |
.. code-block:: bash | ||
export AIRFLOW_CONN_GOOGLE_CLOUD_SQL_DEFAULT='gcpcloudsql://user:[email protected]:3306/mydb?database_type=mysql&project_id=example-project&location=europe-west1&instance=testinstance&use_proxy=True&sql_proxy_use_tcp=False' | ||
Configuring and using IAM authentication | ||
---------------------------------------- | ||
|
||
.. warning:: | ||
This functionality requires ``gcloud`` command (Google Cloud SDK) must be `installed | ||
<https://cloud.google.com/sdk/docs/install>`_ on the Airflow worker. | ||
|
||
.. warning:: | ||
IAM authentication working only for Google Service Accounts. | ||
|
||
Configure Service Accounts on Google Cloud IAM side | ||
""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
|
||
For connecting via IAM you need to use Service Account. It can be the same service account which you use for | ||
the ``gcloud`` authentication or an another account. If you decide to use a different account then this | ||
account should be impersonated from the account which used for ``gcloud`` authentication and granted | ||
a ``Service Account Token Creator`` role. More information how to grant a role `here | ||
<https://cloud.google.com/iam/docs/manage-access-service-accounts?hl=en&_gl=1*3bsv5i*_ga*NDY4NDIyNTcxLjE3MjkxNzQ4MTM.*_ga_WH2QY8WWF5*MTcyOTE5MzU1OS4yLjEuMTcyOTE5NTM0My4wLjAuMA..#single-role>`_. | ||
|
||
Also the Service Account should be configured for working with IAM. | ||
Here are links describing what should be done before the start: | ||
`PostgreSQL<https://cloud.google.com/sql/docs/postgres/iam-logins#before_you_begin>`_ and | ||
`MySQL<https://cloud.google.com/sql/docs/mysql/iam-logins#before_you_begin>`_. | ||
|
||
Configure ``gcpcloudsql`` connection with IAM enabling | ||
"""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
|
||
For using IAM you need to enable ``"use_iam": "True"`` in the ``extra`` field. And specify IAM account in this format | ||
``USERNAME@PROJECT_ID.iam.gserviceaccount.com`` in ``login`` field and empty string in the ``password`` field. | ||
|
||
For example: | ||
|
||
.. exampleinclude:: /../../providers/tests/system/google/cloud/cloud_sql/example_cloud_sql_query_iam.py | ||
:language: python | ||
:dedent: 4 | ||
:start-after: [START howto_operator_cloudsql_iam_connections] | ||
:end-before: [END howto_operator_cloudsql_iam_connections] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.