Events
topology.yml
name: TOPOLOGY
events: EventName: producer: String or Array producers: Array filter: <filter-expression> pattern: <JSON Event Pattern> function: <function1> functions: - <function1> - <function2> mutation: <mutationName> state: <state-or-stepfn-fqn> channel: <room1> rule_name: <static-rule-name> doc_only: <bool>Filters
Section titled “Filters”events: MyRawEvent: filter: '{"detail_type": ["FooBar"]}' function: '{{namespace}}_foo_{{sandbox}}' MyFilterEvent: producer: default filter: '{"metadata": {"type": ["foo"]}}' function: '{{namespace}}_foo_{{sandbox}}' MyAbstractEvent: producer: default function: '{{namespace}}_foo_{{sandbox}}'tc compiles JSON path filters to rules.
Patterns
Section titled “Patterns”If we have more complex patterns that can’t fit into basic producer/filter keys, we can specify a JSON blob containing the pattern
events: MyEvent: pattern: '{"detail-type": ["foo"], "source": ["aws.s3"]}' function: fooTriggers
Section titled “Triggers”Pre-defined Triggers
Section titled “Pre-defined Triggers”tc provides pre-defined triggers
events: MyEvent: producer: S3/PUT_OBJECT filter: '{"key": "foo/bar.png"}' function: function1The following are available triggers for AWS provider
| Resource | Trigger | Description |
|---|---|---|
| Cognito | PRE_SIGNUP | |
| Cognito | POST_CONFIRMATION | |
| Cognito | PRE_AUTHENTICATION | |
| Cognito | POST_AUTHENTICATION | |
| Cognito | CREATE_AUTH_CHALLENGE | |
| Cognito | VERIFY_AUTH_CHALLENGE_RESPONSE | |
| S3 | PUT_OBJECT | |
| S3 | DELETE_OBJECT | |
| DYNAMODB | PUT_ITEM |
Schedules
Section titled “Schedules”A schedule is a special kind of event. However, due to it’s complexity and fixed payload configuration, they are defined in a separate file. For example, in `{INFRA_DIR}/
{ "run-task1": { "cron": "10 20 ? * SAT *", "target": "arn:aws:states:{{region}}:{{account}}:stateMachine:s1", "payload": { "account": "{{account}}", "region": "{{region}}", "target": "nightly", "job_id": "nightly", "task_name": "task1" } }, "run-task2": { "cron": "20 20 ? * SAT *", "target": "arn:aws:states:{{region}}:{{account}}:function:f1", "payload": { "account": "{{account}}", "region": "{{region}}", "target": "nightly", "job_id": "nightly", "task_name": "task2" } }}To update just the schedules
tc update -s sandbox -e profile -c schedulesComposition
Section titled “Composition”Events can be composed with other entities. For example:
events: ApiEvent: function: function1
events: StateEvent: state: state-fqn MyOtherStateEvent: state: '{{namespace}}_{{sandbox}}'Invoke
Section titled “Invoke”To invoke an event with just the payload data ($.detail), do:
tc invoke -s SANDBOX -e PROFILE -c events/MyEvent -p payload.json# or from s3tc invoke -s SANDBOX -e PROFILE -c events/MyEvent -p s3://bucket/payload.json