/
RuleProps.go
73 lines (70 loc) · 2.86 KB
/
RuleProps.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
package awsevents
import (
"github.com/aws/constructs-go/constructs/v10"
)
// Properties for defining an EventBridge Rule.
//
// Example:
// import "github.com/aws/aws-cdk-go/awscdk"
//
//
// fn := lambda.NewFunction(this, jsii.String("MyFunc"), &FunctionProps{
// Runtime: lambda.Runtime_NODEJS_14_X(),
// Handler: jsii.String("index.handler"),
// Code: lambda.Code_FromInline(jsii.String("exports.handler = handler.toString()")),
// })
//
// rule := events.NewRule(this, jsii.String("rule"), &RuleProps{
// EventPattern: &EventPattern{
// Source: []*string{
// jsii.String("aws.ec2"),
// },
// },
// })
//
// queue := sqs.NewQueue(this, jsii.String("Queue"))
//
// rule.AddTarget(targets.NewLambdaFunction(fn, &LambdaFunctionProps{
// DeadLetterQueue: queue,
// // Optional: add a dead letter queue
// MaxEventAge: awscdk.Duration_Hours(jsii.Number(2)),
// // Optional: set the maxEventAge retry policy
// RetryAttempts: jsii.Number(2),
// }))
//
type RuleProps struct {
// The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region).
//
// This helps dealing with cycles that often arise in these situations.
CrossStackScope constructs.Construct `field:"optional" json:"crossStackScope" yaml:"crossStackScope"`
// A description of the rule's purpose.
Description *string `field:"optional" json:"description" yaml:"description"`
// Additional restrictions for the event to route to the specified target.
//
// The method that generates the rule probably imposes some type of event
// filtering. The filtering implied by what you pass here is added
// on top of that filtering.
// See: https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-and-event-patterns.html
//
EventPattern *EventPattern `field:"optional" json:"eventPattern" yaml:"eventPattern"`
// A name for the rule.
RuleName *string `field:"optional" json:"ruleName" yaml:"ruleName"`
// Indicates whether the rule is enabled.
Enabled *bool `field:"optional" json:"enabled" yaml:"enabled"`
// The event bus to associate with this rule.
EventBus IEventBus `field:"optional" json:"eventBus" yaml:"eventBus"`
// The schedule or rate (frequency) that determines when EventBridge runs the rule.
//
// You must specify this property, the `eventPattern` property, or both.
//
// For more information, see Schedule Expression Syntax for
// Rules in the Amazon EventBridge User Guide.
// See: https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html
//
Schedule Schedule `field:"optional" json:"schedule" yaml:"schedule"`
// Targets to invoke when this rule matches an event.
//
// Input will be the full matched event. If you wish to specify custom
// target input, use `addTarget(target[, inputOptions])`.
Targets *[]IRuleTarget `field:"optional" json:"targets" yaml:"targets"`
}