/
serverless.yml
174 lines (169 loc) · 4.8 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
service: serverless-github-data
plugins:
- serverless-webpack
- serverless-dynamodb-local
- serverless-offline
- serverless-domain-manager
custom:
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
serverless-offline:
port: 3002
githubMembersTableName: "github-members-table-${self:provider.stage}"
githubReposTableName: "github-repos-table-${self:provider.stage}"
slackTableName: "slack-table-${self:provider.stage}"
ghostTableName: "ghost-table-${self:provider.stage}"
dynamodb:
start:
migrate: true
stages:
- dev
customDomain:
domainName: stats.openmined.org
stage: prod
createRoute53Record: true
certificateArn: arn:aws:acm:us-east-1:273848247695:certificate/5dfde36f-db45-4557-bf88-8fcd42cbc2a5
provider:
name: aws
runtime: nodejs8.10
stage: ${opt:stage, 'dev'}
profile: openmined
region: us-east-1
environment:
GITHUB_TOKEN: ${file(./env.yml):GITHUB_TOKEN}
MAPBOX_TOKEN: ${file(./env.yml):MAPBOX_TOKEN}
SLACK_TOKEN: ${file(./env.yml):SLACK_TOKEN}
OPENMINED_BLOG_TOKEN: ${file(./env.yml):OPENMINED_BLOG_TOKEN}
GITHUB_MEMBERS_TABLE: ${self:custom.githubMembersTableName}
GITHUB_REPOS_TABLE: ${self:custom.githubReposTableName}
SLACK_TABLE: ${self:custom.slackTableName}
GHOST_TABLE: ${self:custom.ghostTableName}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:BatchWriteItem
- dynamodb:DescribeTable
Resource:
- { "Fn::GetAtt": ["GithubMembersDynamoDBTable", "Arn"] }
- { "Fn::GetAtt": ["GithubReposDynamoDBTable", "Arn"] }
- { "Fn::GetAtt": ["SlackDynamoDBTable", "Arn"] }
- { "Fn::GetAtt": ["GhostDynamoDBTable", "Arn"] }
functions:
deliverGithub:
handler: index.deliverGithub
events:
- http:
path: github
method: get
cors: true
updateGithub:
handler: index.updateGithub
timeout: 30
events:
- http:
path: github
method: post
cors: true
- schedule:
name: update-github-cron
description: "Updates our DynamoDB table with the latest Github stats via a CRON job."
rate: rate(1 day)
deliverSlack:
handler: index.deliverSlack
events:
- http:
path: slack
method: get
cors: true
updateSlack:
handler: index.updateSlack
timeout: 30
events:
- http:
path: slack
method: post
cors: true
- schedule:
name: update-slack-cron
description: "Updates our DynamoDB table with the latest Slack stats via a CRON job."
rate: rate(1 day)
deliverGhost:
handler: index.deliverGhost
events:
- http:
path: ghost
method: get
cors: true
updateGhost:
handler: index.updateGhost
timeout: 30
events:
- http:
path: ghost
method: post
cors: true
- schedule:
name: update-ghost-cron
description: "Updates our DynamoDB table with the latest Ghost posts via a CRON job."
rate: rate(1 hour)
resources:
Resources:
GithubMembersDynamoDBTable:
Type: "AWS::DynamoDB::Table"
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:custom.githubMembersTableName}
GithubReposDynamoDBTable:
Type: "AWS::DynamoDB::Table"
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:custom.githubReposTableName}
SlackDynamoDBTable:
Type: "AWS::DynamoDB::Table"
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 10
TableName: ${self:custom.slackTableName}
GhostDynamoDBTable:
Type: "AWS::DynamoDB::Table"
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:custom.ghostTableName}