-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventbridge.go
75 lines (66 loc) · 1.83 KB
/
eventbridge.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// Copyright (C) 2021 - 2022 Dmitry Kolesnikov
//
// This file may be modified and distributed under the terms
// of the Apache License Version 2.0. See the LICENSE file for details.
// https://github.com/fogfish/swarm
//
package main
import (
"os"
"github.com/aws/aws-cdk-go/awscdk/v2"
"github.com/aws/jsii-runtime-go"
"github.com/fogfish/scud"
"github.com/fogfish/swarm/broker/eventbridge"
)
func main() {
app := awscdk.NewApp(nil)
stack := awscdk.NewStack(app, jsii.String("swarm-example-eventbridge"),
&awscdk.StackProps{
Env: &awscdk.Environment{
Account: jsii.String(os.Getenv("CDK_DEFAULT_ACCOUNT")),
Region: jsii.String(os.Getenv("CDK_DEFAULT_REGION")),
},
},
)
//
broker := eventbridge.NewBroker(stack, jsii.String("Broker"), nil)
broker.NewEventBus(nil)
broker.NewSink(
&eventbridge.SinkProps{
EventPattern: eventbridge.Like(
eventbridge.Source("swarm-example-eventbridge"),
eventbridge.Category("User", "Note", "Like"),
),
Function: &scud.FunctionGoProps{
SourceCodeModule: "github.com/fogfish/swarm/broker/eventbridge",
SourceCodeLambda: "examples/dequeue/typed",
},
},
)
broker.NewSink(
&eventbridge.SinkProps{
EventPattern: eventbridge.Like(
eventbridge.Source("swarm-example-eventbridge"),
eventbridge.Category("EventNote"),
),
Function: &scud.FunctionGoProps{
SourceCodeModule: "github.com/fogfish/swarm/broker/eventbridge",
SourceCodeLambda: "examples/dequeue/event",
},
},
)
broker.NewSink(
&eventbridge.SinkProps{
EventPattern: eventbridge.Like(
eventbridge.Source("swarm-example-eventbridge"),
eventbridge.Category("User", "Note", "Like"),
),
Function: &scud.FunctionGoProps{
SourceCodeModule: "github.com/fogfish/swarm/broker/eventbridge",
SourceCodeLambda: "examples/dequeue/bytes",
},
},
)
app.Synth(nil)
}