-
Notifications
You must be signed in to change notification settings - Fork 5
Design : Watcher : Prefix
The watcher prefix component is responsible for automatically adding and removing replications for prefixed dynamodb tables as they are created and deleted. It consists of a DynamoDB table, two CloudWatch event rules, and three Lambda functions.
The prefix dynamodb table holds items for each prefix being watched. Replications will be automatically created and removed for tables that match any of the prefixes stored in this table. Whenever a new prefix is added, replications will be automatically added for all matching tables that already exist. Deleting a prefix has no effect on active replications.
Create - [src]
The create function is triggered by a CloudWatch event rule whenever a new DynamoDB table is created. It compares the name of the newly created table to the contents of the prefix table. If any of the prefixes match, it creates a new replication for the table. The new replication is created by adding a new item to the controller table in the VALIDATE_SOURCE step.
Delete - [src]
The delete function is triggered by a CloudWatch event rule whenever a DynamoDB table is deleted. If the table is being replicated, it removes the replication. The replication is removed by updating the item in the controller table (if it exists) to the STOP_REPLICATION step.
Init - [src]
The init function is run whenever a new prefix is added to the prefix table. It queries dynamodb for a list of existing tables named with this prefix. It then starts replication for any tables found. To start the replication, the init function constructs and posts a mock CreateTable event to CloudWatch, triggering the CreateFunction to handle the rest.