-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
146 lines (141 loc) · 3.2 KB
/
serverless.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
service:
name: yyt-leaderboard-api
plugins:
- serverless-webpack
- serverless-offline
- serverless-prune-plugin
- serverless-plugin-warmup
provider:
name: aws
runtime: nodejs10.x
stage: production
region: ap-northeast-2
tracing:
apiGateway: true
lambda: true
iamRoleStatements:
- Effect: "Allow"
Action:
- "s3:GetObject"
- "s3:PutObject"
Resource:
- "arn:aws:s3:::${env:BUCKET_NAME}/*"
- Effect: "Allow"
Action:
- "s3:ListBucket"
Resource:
- "arn:aws:s3:::${env:BUCKET_NAME}"
- Effect: Allow
Action:
- lambda:InvokeFunction
Resource:
- Fn::Join:
- ":"
- - "arn:aws:lambda"
- Ref: "AWS::Region"
- Ref: "AWS::AccountId"
- "function"
- ${self:custom.putLambda}
- Fn::Join:
- ":"
- - "arn:aws:lambda"
- Ref: "AWS::Region"
- Ref: "AWS::AccountId"
- "function"
- ${self:custom.bottomHalfLambda}
environment:
REDIS_HOST: ${env:REDIS_HOST}
REDIS_PASSWORD: ${env:REDIS_PASSWORD}
BUCKET_NAME: ${env:BUCKET_NAME}
AUTH_KEY: ${env:AUTH_KEY, ""}
BOTTOM_HALF_LAMBDA: ${self:custom.bottomHalfLambda}
DEBUG: ${env:DEBUG, ""}
ELAPSED: ${env:ELAPSED, "1"}
usagePlan:
quota:
limit: 100000
period: DAY
throttle:
burstLimit: 240
rateLimit: 60
custom:
putLambda: ${self:service.name}-${self:provider.stage}-put
bottomHalfLambda: ${self:service.name}-${self:provider.stage}-bottomHalf
prune:
automatic: true
number: 7
warmup:
enable: true
prewarm: true
events:
- schedule: "cron(0/10 * ? * * *)" # Run WarmUp every 10 minutes.
functions:
get:
handler: src/handler.get
events:
- http:
method: get
path: /{serviceId}/{period}
cors: true
me:
handler: src/handler.me
events:
- http:
method: get
path: /{serviceId}/{period}/me
cors: true
top:
handler: src/handler.top
events:
- http:
method: get
path: /{serviceId}/{period}/top
cors: true
around:
handler: src/handler.around
events:
- http:
method: get
path: /{serviceId}/{period}/around
cors: true
scrollUp:
handler: src/handler.scrollUp
events:
- http:
method: get
path: /{serviceId}/{period}/up
cors: true
scrollDown:
handler: src/handler.scrollDown
events:
- http:
method: get
path: /{serviceId}/{period}/down
cors: true
put:
handler: src/handler.put
timeout: 10
memorySize: 2048
events:
- http:
method: put
path: /{serviceId}/{period}
cors: true
warmup:
enabled: true
bottomHalf:
handler: src/handler.bottomHalf
timeout: 900
clear:
handler: src/handler.clear
events:
- http:
method: delete
path: /{serviceId}/{period}
cors: true
resources:
Resources:
DistBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${env:BUCKET_NAME}