-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
222 lines (208 loc) · 8.01 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
service:
name: DevsTopics
package:
individually: true
plugins:
- serverless-webpack
- serverless-iam-roles-per-function
- serverless-prune-plugin
- serverless-offline-sns
- serverless-dynamodb-local
- serverless-offline
custom: ${file(./serverless.env.yml)}
resources:
Resources:
postsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.tables.posts.name}
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: site
AttributeType: S
- AttributeName: publishedAt
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
GlobalSecondaryIndexes:
- IndexName: ${self:custom.tables.posts.indexes.publishedAtAndSite}
KeySchema:
- AttributeName: site
KeyType: HASH
- AttributeName: publishedAt
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
Projection:
ProjectionType: ALL
provider:
name: aws
runtime: nodejs12.x
frameworkVersion: ‘1.64.1’
stage: ${opt:stage, 'development'}
region: ${opt:region, 'eu-west-1'}
apiGateway:
minimumCompressionSize: 1024 # Enable gzip compression for responses > 1 KB
environment:
DEBUG: '*'
NODE_ENV: ${self:provider.stage}
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
SLS_DEBUG: '*'
tracing:
lambda: false
iamRoleStatements:
- Effect: Allow
Action:
- xray:PutTraceSegments
- xray:PutTelemetryRecords
Resource: "*"
functions:
hackernoon:
handler: src/sources/hackerNoon/hackerNoonHandler.findPosts
name: "hackernoon-scrapper-${self:provider.stage}"
memorySize: 256
events:
- http:
method: get
path: hackernoon
environment:
PUBLISH_TOPIC_ARN: ${self:custom.newPostsFoundSnsTopicArn.${self:provider.stage}}
SNS_ENDPOINT_URL: ${self:custom.snsHostURL.${self:provider.stage}}
RSS_FEED_URL: "https://hackernoon.com/feed"
iamRoleStatements:
- Effect: Allow
Action: SNS:Publish
Resource: { "Fn::Join": ["", ["arn:aws:sns:${self:provider.region}:", { "Ref": "AWS::AccountId" }, ":${self:custom.newPostsFoundSnsTopic}" ] ] }
hackernews:
handler: src/sources/hackerNews/hackerNewsHandler.findPosts
name: "hackernews-scrapper-${self:provider.stage}"
memorySize: 256
events:
- http:
method: get
path: hackernews
environment:
PUBLISH_TOPIC_ARN: ${self:custom.newPostsFoundSnsTopicArn.${self:provider.stage}}
SNS_ENDPOINT_URL: ${self:custom.snsHostURL.${self:provider.stage}}
RSS_FEED_URL: "https://hnrss.org/newest?points=100"
iamRoleStatements:
- Effect: Allow
Action: SNS:Publish
Resource: { "Fn::Join": ["", ["arn:aws:sns:${self:provider.region}:", { "Ref": "AWS::AccountId" }, ":${self:custom.newPostsFoundSnsTopic}" ] ] }
devto:
handler: src/sources/devTo/devToHandler.findPosts
name: "devto-scrapper-${self:provider.stage}"
memorySize: 256
events:
- http:
method: get
path: devto
environment:
PUBLISH_TOPIC_ARN: ${self:custom.newPostsFoundSnsTopicArn.${self:provider.stage}}
SNS_ENDPOINT_URL: ${self:custom.snsHostURL.${self:provider.stage}}
RSS_FEED_URL: "https://dev.to/feed"
iamRoleStatements:
- Effect: Allow
Action: SNS:Publish
Resource: { "Fn::Join": ["", ["arn:aws:sns:${self:provider.region}:", { "Ref": "AWS::AccountId" }, ":${self:custom.newPostsFoundSnsTopic}" ] ] }
infoq:
handler: src/sources/infoQ/infoQHandler.findPosts
name: "infoq-scrapper-${self:provider.stage}"
memorySize: 256
events:
- http:
method: get
path: infoq
environment:
PUBLISH_TOPIC_ARN: ${self:custom.newPostsFoundSnsTopicArn.${self:provider.stage}}
SNS_ENDPOINT_URL: ${self:custom.snsHostURL.${self:provider.stage}}
RSS_FEED_URL: "https://feed.infoq.com/"
iamRoleStatements:
- Effect: Allow
Action: SNS:Publish
Resource: { "Fn::Join": ["", ["arn:aws:sns:${self:provider.region}:", { "Ref": "AWS::AccountId" }, ":${self:custom.newPostsFoundSnsTopic}" ] ] }
dZone:
handler: src/sources/dZone/dZoneHandler.findPosts
name: "dzone-scrapper-${self:provider.stage}"
memorySize: 256
events:
- http:
method: get
path: dzone
environment:
PUBLISH_TOPIC_ARN: ${self:custom.newPostsFoundSnsTopicArn.${self:provider.stage}}
SNS_ENDPOINT_URL: ${self:custom.snsHostURL.${self:provider.stage}}
RSS_FEED_URL: "http://feeds.dzone.com/home"
iamRoleStatements:
- Effect: Allow
Action: SNS:Publish
Resource: { "Fn::Join": ["", ["arn:aws:sns:${self:provider.region}:", { "Ref": "AWS::AccountId" }, ":${self:custom.newPostsFoundSnsTopic}" ] ] }
postsListener:
handler: src/management/postsListenerHandler.listen
name: "posts-listener-${self:provider.stage}"
memorySize: 256
environment:
POSTS_TABLE_NAME: ${self:custom.tables.posts.name}
DYNAMODB_ENDPOINT_URL: ${self:custom.dynamodb.endpoint.${self:provider.stage}}
events:
- sns:
displayName: ${self:custom.newPostsFoundSnsTopic}
topicName: ${self:custom.newPostsFoundSnsTopic}
iamRoleStatements:
- Effect: "Allow"
Action: dynamodb:PutItem
Resource: { "Fn::Join": ["", ["arn:aws:dynamodb:${self:provider.region}:", { "Ref": "AWS::AccountId" }, ":table/${self:custom.tables.posts.name}" ] ] }
postPromoter:
handler: src/management/simplePostFanHandler.publish
name: "post-promoter-${self:provider.stage}"
memorySize: 200
environment:
POSTS_TABLE_NAME: ${self:custom.tables.posts.name}
POSTS_PUBLISHED_AT_SITE_INDEX_NAME: ${self:custom.tables.posts.indexes.publishedAtAndSite}
DYNAMODB_ENDPOINT_URL: ${self:custom.dynamodb.endpoint.${self:provider.stage}}
PUBLISH_TOPIC_ARN: ${self:custom.newPostCandidateToPublishTopicArn.${self:provider.stage}}
SNS_ENDPOINT_URL: ${self:custom.snsHostURL.${self:provider.stage}}
events:
- http:
method: get
path: promoter
iamRoleStatements:
- Effect: "Allow"
Action: dynamodb:Query
Resource: { "Fn::Join": ["", ["arn:aws:dynamodb:${self:provider.region}:", { "Ref": "AWS::AccountId" }, ":table/${self:custom.tables.posts.name}/index/${self:custom.tables.posts.indexes.publishedAtAndSite}" ] ] }
- Effect: Allow
Action: SNS:Publish
Resource: { "Fn::Join": ["", ["arn:aws:sns:${self:provider.region}:", { "Ref": "AWS::AccountId" }, ":${self:custom.newPostCandidateToPublishTopic}" ] ] }
telegramPublisher:
handler: src/promoters/telegram/telegramPublisherHandler.publish
name: "telegram-publisher-${self:provider.stage}"
memorySize: 200
environment:
TELEGRAM_CHANNEL_ID: ${self:custom.TELEGRAM_CHANNEL_ID}
TELEGRAM_BOT_TOKEN: ${self:custom.TELEGRAM_BOT_TOKEN}
TELEGRAM_MAX_NUMBER_OF_MESSAGES: 3
events:
- sns:
displayName: ${self:custom.newPostCandidateToPublishTopic}
topicName: ${self:custom.newPostCandidateToPublishTopic}
twitterPublisher:
handler: src/promoters/twitter/twitterPublisherHandler.publish
name: "twitter-publisher-${self:provider.stage}"
memorySize: 200
environment:
TWITTER_APP_API_KEY: ${self:custom.TWITTER_APP_API_KEY}
TWITTER_APP_API_SECRET: ${self:custom.TWITTER_APP_API_SECRET}
TWITTER_APP_ACCESS_TOKEN_KEY: ${self:custom.TWITTER_APP_ACCESS_TOKEN_KEY}
TWITTER_APP_ACCESS_TOKEN_SECRET: ${self:custom.TWITTER_APP_ACCESS_TOKEN_SECRET}
TWITTER_TWEET_MAX_LENGTH: 280
TWITTER_MAX_NUMBER_OF_TWEETS: 3
events:
- sns:
displayName: ${self:custom.newPostCandidateToPublishTopic}
topicName: ${self:custom.newPostCandidateToPublishTopic}