-
Notifications
You must be signed in to change notification settings - Fork 18
/
stack.go
58 lines (50 loc) · 1.39 KB
/
stack.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
package main
import (
"fmt"
cdk "github.com/aws/aws-cdk-go/awscdk/v2"
cloudwatch "github.com/aws/aws-cdk-go/awscdk/v2/awscloudwatch"
"github.com/aws/constructs-go/constructs/v10"
"github.com/aws/jsii-runtime-go"
)
type CloudwatchStackProps struct {
cdk.StackProps
/// Environment used for this deployment.
EnvironmentName *string
}
type CloudwatchStack struct {
cdk.Stack
}
func NewCloudwatchStack(scope constructs.Construct, id string, props *CloudwatchStackProps) *CloudwatchStack {
var sprops cdk.StackProps
if props != nil {
sprops = props.StackProps
}
stack := cdk.NewStack(scope, &id, &sprops)
cloud_watch.NewCfnAlarm(
stack,
jsii.String("MyApi5xxErrorsAlarm"),
&cloud_watch.CfnAlarmProps{
AlarmDescription: jsii.String("Example alarm"),
Namespace: jsii.String("AWS/ApiGateway"),
Dimensions: &[]interface{}{
&DimensionProperty{
Name: jsii.String("ApiName"),
Value: jsii.String("MyApi"),
},
},
MetricName: jsii.String("5XXError"),
ComparisonOperator: jsii.String("GreaterThanThreshold"),
Statistic: jsii.String("Average"),
Threshold: jsii.Number(0),
Period: jsii.Number(900),
EvaluationPeriods: jsii.Number(1),
TreatMissingData: jsii.String("notBreaching"),
AlarmActions: &[]*string{
cdk.Fn_ImportValue(jsii.String(fmt.Sprintf("%vAlarmsTopicArn", props.EnvironmentName))),
},
},
)
return &CloudwatchStack{
Stack: stack,
}
}