How-to Guide for Chime notifications

Introduction

Chime notifier (airflow.providers.amazon.aws.notifications.chime.ChimeNotifier) allows users to send messages to a Chime chat room setup via a webhook using the various on_*_callbacks at both the DAG level and Task level

Example Code:

from datetime import datetime
from airflow import DAG
from airflow.providers.standard.operators.bash import BashOperator
from airflow.providers.amazon.aws.notifications.chime import send_chime_notification

with DAG(
    dag_id="mydag",
    schedule="@once",
    start_date=datetime(2023, 6, 27),
    on_success_callback=[
        send_chime_notification(chime_conn_id="my_chime_conn", message="The DAG {{ dag.dag_id }} succeeded")
    ],
    catchup=False,
):
    BashOperator(
        task_id="mytask",
        on_failure_callback=[
            send_chime_notification(chime_conn_id="my_chime_conn", message="The task {{ ti.task_id }} failed")
        ],
        bash_command="fail",
    )

Was this entry helpful?