Reputation: 93
I am trying to set up email notifications in Composer but for a Private Composer instance, following the instructions here: https://cloud.google.com/composer/docs/how-to/managing/creating#configuring_sendgrid_email_services
The 'how-to' page does note that "Note: If your Cloud Composer environment is configured for Private IP, make sure that it has connectivity to the API endpoint for your external email service (such as https://api.sendgrid.com, or your preferred SMTP server)."
To test it out, in Google Cloud, I created an VPC Egress firewall rule for all targets and all ports, with an IP range of 0.0.0.0/0.
I have also set up a Sendgrid account, confirmed single sender verification for the email I'm sending it out from (same domain), and set IP access management to allow 0.0.0.0.
Lastly, I input the necessary information in the Airflow config file.
[email]
email_backend = airflow.contrib.utils.sendgrid.send_email
SENDGRID_MAIL_FROM = [[email protected]]
SENDGRID_API_KEY = SG.[***]
[smtp]
smtp_host = smtp-relay.gmail.com
smtp_starttls = True
smtp_ssl = False
smtp_user = [[email protected]]
smtp_port = 587
smtp_password = [*****]
smtp_mail_from = [[email protected]]
However, when I run the DAG to send an email, I still get an error WARNING - Failed to send out email with subject Airflow Alert, error: HTTP Error 401: Unauthorized
Is there something I would need to do for a private Composer instance that I am missing?
Thanks!
Upvotes: 1
Views: 1217
Reputation: 93
Resolved by changing the environment variables as per the instructions and not the config file directly.
https://cloud.google.com/composer/docs/how-to/managing/creating#configuring_sendgrid_email_services
Upvotes: 2