I have requirement to send notification email, once a Google Cloud Composer airflow DAG is completed. I have come to a solution and used sendGrid as suggested in Google Documents.
But the problem is API key is visible who has access of cloud composer as it is assigned to an Environment variable. When I used the same key in my local systems python program, it is sending mail and that is where I don't understand this conecept. Because if someone has this API key or someone has shared the same it is not project specific anyone can send mail using this key.
Could some one help me, how to secure sendGrid API key.
Analyzing and gathering the evidence of the community contributors in the relevant Stack thread1 and thread2 I would propose you to re-consider the general approach and use JSON file to store the credentials or the other sensitive system authentication data by specifying Keyfile Path in the corresponded Airflow connection.
/home/airflow/gcs/data/keyfile.json
);Since Airflow connection has been created you may refer to the encrypted API key within GoogleCloudBaseHook operator via predefined
extra__google_cloud_platform__key_path
query parameter in the particular DAG code: