Could anyone please let me know if there is a way to configure SMS notification through airflow. I am using AWS so if there is a way I can publish message to SNS then also it should work.
Could anyone please let me know if there is a way to configure SMS notification through airflow. I am using AWS so if there is a way I can publish message to SNS then also it should work.
You can use on_failure_callback and define whatever logic you require.
Since Airflow has SnsPublishOperator you can use it inside your python function.
from airflow.providers.amazon.aws.operators.sns import SnsPublishOperator
def on_failure_callback(context):
op = SnsPublishOperator(
task_id='failure',
aws_conn_id=AWS_CONN_ID,
target_arn=TARGET_ARN,
message="Dag Failed",
subject="Dag Failed",
)
op.execute()
dag = DAG(
dag_id='my_dag',
start_date=datetime(2020, 12, 05),
on_failure_callback=on_failure_callback,
default_args={'on_failure_callback': on_failure_callback}
)