Amazon DynamoDB¶
Amazon DynamoDB Amazon DynamoDB is a fully managed, serverless, key-value NoSQL database designed to run high-performance applications at any scale. DynamoDB offers built-in security, continuous backups, automated multi-Region replication, in-memory caching, and data import and export tools.
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 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
Sensors¶
Wait on Amazon DynamoDB item attribute value match¶
Use the DynamoDBValueSensor
to wait for the presence of a matching DynamoDB item’s attribute/value pair.
Wait for a Single Attribute Value Match:¶
This example shows how to use DynamoDBValueSensor
to wait for a specific attribute/value pair in a DynamoDB item.
tests/system/amazon/aws/example_dynamodb.py
dynamodb_sensor = DynamoDBValueSensor(
task_id="waiting_for_dynamodb_item_value",
table_name=table_name,
partition_key_name=PK_ATTRIBUTE_NAME,
partition_key_value="Test",
sort_key_name=SK_ATTRIBUTE_NAME,
sort_key_value="2022-07-12T11:11:25-0400",
attribute_name="Value",
attribute_value="Testing",
)
Wait for Any Value from a List of Attribute Values:¶
In this example, the sensor waits for the DynamoDB item to have an attribute that matches any value from a provided list.
tests/system/amazon/aws/example_dynamodb.py
dynamodb_sensor_any_value = DynamoDBValueSensor(
task_id="waiting_for_dynamodb_item_any_value",
table_name=table_name,
partition_key_name=PK_ATTRIBUTE_NAME,
partition_key_value="Test",
sort_key_name=SK_ATTRIBUTE_NAME,
sort_key_value="2022-07-12T11:11:25-0400",
attribute_name="Value",
attribute_value=["Foo", "Testing", "Bar"],
)