-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtemplate.yml
79 lines (72 loc) · 1.91 KB
/
template.yml
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
76
77
78
79
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Parameters:
DomainName:
Type: String
ACMCertificateArn:
Type: String
Version:
Type: String
Resources:
Gateway:
Type: AWS::Serverless::HttpApi
Properties:
Domain:
DomainName: !Ref DomainName
CertificateArn: !Ref ACMCertificateArn
ErrorMetricFilter:
Type: AWS::Logs::MetricFilter
Properties:
LogGroupName: !Join ["/", ["/aws", "lambda", !Ref MainFunction]]
FilterPattern: '{$.level = "error"}'
MetricTransformations:
- MetricValue: "1"
MetricNamespace: !Sub ${AWS::StackName}
MetricName: ErrorMetricFilter
EmailSNSTopic:
Type: AWS::SNS::Topic
Properties:
Subscription:
- Protocol: email
Endpoint: [email protected]
LogAlarmResource:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmName: ErrorLogs
AlarmDescription: Alarm when lambda errors
ComparisonOperator: GreaterThanThreshold
EvaluationPeriods: 1
MetricName: ErrorMetricFilter
Namespace: !Sub ${AWS::StackName}
Threshold: 0.0
Period: 60
Statistic: Sum
TreatMissingData: notBreaching
AlarmActions:
- !Ref EmailSNSTopic
DependsOn: EmailSNSTopic
MainFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: ltabus
Architectures:
- arm64
CodeUri: .
Handler: main
Runtime: provided.al2
Events:
CatchAll:
Type: HttpApi
Properties:
ApiId: !Ref Gateway
Path: /{proxy+}
Method: ANY
Environment:
Variables:
ACCOUNTKEY: "{{resolve:ssm:/ltabus/accountkey:1}}"
VERSION: !Ref Version
Metadata:
BuildMethod: makefile
Outputs:
GatewayEndPoint:
Value: !Sub "https://${Gateway}.execute-api.${AWS::Region}.amazonaws.com/"