-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.yml
More file actions
165 lines (157 loc) · 4.15 KB
/
serverless.yml
File metadata and controls
165 lines (157 loc) · 4.15 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
service:
name: chee
awsKmsKeyArn: arn:aws:kms:us-east-1:710390882138:key/bbbc300d-ac65-4e10-a4d8-4ae43008ae13
package:
include:
- lib/**
- data/**
- conf/**
- node_modules/serverless-dynamodb-local/**
exclude:
- README.md
- Makefile
- LICENSE
custom:
creds: ${file(./config.yml)}
bucket: chee
ccl_bucket: tds-slack
tables:
users: karma_users
scores: karma_scores
dynamodb:
start:
inMemory: true
migrate: true
serverless-offline:
port: 4000
provider:
name: aws
memory: 128
runtime: nodejs6.10
timeout: 3
stage: dev
profile: serverless
environment:
SLACK_CLIENT_ID: ${self:custom.creds.slack_client_id}
SLACK_CLIENT_SECRET: ${self:custom.creds.slack_client_secret}
SLACK_VERIFICATION_TOKEN: ${self:custom.creds.slack_verification_token}
MASHAPE_API_KEY: ${self:custom.creds.mashape_api_key}
DYNAMODB_USER_TABLE: ${self:custom.tables.users}
DYNAMODB_SCORE_TABLE: ${self:custom.tables.scores}
iamRoleStatements:
- Effect: Allow
Action:
- s3:*
Resource:
- "arn:aws:s3:::${self:custom.ccl_bucket}/*"
- "arn:aws:s3:::${self:custom.ccl_bucket}"
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/*"
functions:
ccl:
handler: lib/ccl/get.do
name: ${self:provider.stage}-ccl
description: Too many ccliters gifs
events:
- http:
path: ccl
method: post
plus:
handler: lib/score/score.plus
name: ${self:provider.stage}-score-plus
description: ++ a thing
events:
- http:
path: score/plus
method: post
minus:
handler: lib/score/score.minus
name: ${self:provider.stage}-score-minus
description: -- a thing
events:
- http:
path: score/minus
method: post
top:
handler: lib/score/score.top
name: ${self:provider.stage}-score-top
description: Get top scorers
events:
- http:
path: score/top
method: post
resources:
Resources:
usersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.tables.users}
AttributeDefinitions:
- AttributeName: team_id
AttributeType: S
- AttributeName: name
AttributeType: S
- AttributeName: score
AttributeType: N
- AttributeName: karma
AttributeType: N
KeySchema:
- AttributeName: team_id
KeyType: HASH
- AttributeName: name
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
LocalSecondaryIndexes:
- IndexName : users-team-score
KeySchema:
- AttributeName: team_id
KeyType: HASH
- AttributeName: score
KeyType: RANGE
Projection:
NonKeyAttributes:
- "karma"
- "id"
- "name"
ProjectionType: INCLUDE
- IndexName : users-team-karma
KeySchema:
- AttributeName: team_id
KeyType: HASH
- AttributeName: karma
KeyType: RANGE
Projection:
NonKeyAttributes:
- "score"
- "id"
- "name"
ProjectionType: INCLUDE
scoresTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.tables.scores}
AttributeDefinitions:
- AttributeName: userId
AttributeType: S
- AttributeName: date
AttributeType: N
KeySchema:
- AttributeName: userId
KeyType: HASH
- AttributeName: date
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
plugins:
- serverless-dynamodb-local
- serverless-offline