Amazon EventBridge¶
Amazon Eventbridge is a serverless event bus service that makes it easy to connect your applications with data from a variety of sources. EventBridge delivers a stream of real-time data from your own applications, software-as-a-service (SaaS) applications, and AWS services and routes that data to targets such as AWS Lambda. You can set up routing rules to determine where to send your data to build application architectures that react in real time to all of your data sources. EventBridge enables you to build event-driven architectures that are loosely coupled and distributed.
Prerequisite Tasks¶
To use these operators, you must do a few things:
Create necessary resources using AWS Console or AWS CLI.
Install API libraries via pip.
pip install 'apache-airflow[amazon]'Detailed information is available Installation of Apache Airflow®
Generic Parameters¶
- aws_conn_id
Reference to Amazon Web Services Connection ID. If this parameter is set to
None
then the default boto3 behaviour is used without a connection lookup. Otherwise use the credentials stored in the Connection. Default:aws_default
- region_name
AWS Region Name. If this parameter is set to
None
or omitted then region_name from AWS Connection Extra Parameter will be used. Otherwise use the specified value instead of the connection value. Default:None
- verify
Whether or not to verify SSL certificates.
False
- Do not validate SSL certificates.path/to/cert/bundle.pem - A filename of the CA cert bundle to use. You can specify this argument if you want to use a different CA cert bundle than the one used by botocore.
If this parameter is set to
None
or is omitted then verify from AWS Connection Extra Parameter will be used. Otherwise use the specified value instead of the connection value. Default:None
- botocore_config
The provided dictionary is used to construct a botocore.config.Config. This configuration can be used to configure Avoid Throttling exceptions, timeouts, etc.
{ "signature_version": "unsigned", "s3": { "us_east_1_regional_endpoint": True, }, "retries": { "mode": "standard", "max_attempts": 10, }, "connect_timeout": 300, "read_timeout": 300, "tcp_keepalive": True, }
If this parameter is set to
None
or omitted then config_kwargs from AWS Connection Extra Parameter will be used. Otherwise use the specified value instead of the connection value. Default:None
Note
Specifying an empty dictionary,
{}
, will overwrite the connection configuration for botocore.config.Config
Operators¶
Send events to Amazon EventBridge¶
To send custom events to Amazon EventBridge, use
EventBridgePutEventsOperator
.
put_events = EventBridgePutEventsOperator(task_id="put_events_task", entries=ENTRIES)
Create or update a rule on Amazon EventBridge¶
To create or update a rule on EventBridge, use
EventBridgePutRuleOperator
.
put_rule = EventBridgePutRuleOperator(
task_id="put_rule_task",
name="example_rule",
event_pattern='{"source": ["example.myapp"]}',
description="This rule matches events from example.myapp.",
state="DISABLED",
)
Enable a rule on Amazon EventBridge¶
To enable an existing rule on EventBridge, use
EventBridgeEnableRuleOperator
.
enable_rule = EventBridgeEnableRuleOperator(task_id="enable_rule_task", name="example_rule")
Disable a rule on Amazon EventBridge¶
To disable an existing rule on EventBridge, use
EventBridgeDisableRuleOperator
.
disable_rule = EventBridgeDisableRuleOperator(
task_id="disable_rule_task",
name="example_rule",
)