-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserverless.yml
154 lines (148 loc) · 4.14 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
service: chi-bill-bot
provider:
name: aws
runtime: go1.x
stage: ${opt:stage, 'dev'}
region: us-east-2
environment:
TWITTER_CONSUMER_KEY: ${ssm:/${self:provider.stage}/${self:service}/twitter/consumer-key~true}
TWITTER_CONSUMER_SECRET: ${ssm:/${self:provider.stage}/${self:service}/twitter/consumer-secret~true}
TWITTER_ACCESS_TOKEN: ${ssm:/${self:provider.stage}/${self:service}/twitter/access-token~true}
TWITTER_ACCESS_SECRET: ${ssm:/${self:provider.stage}/${self:service}/twitter/access-secret~true}
RDS_DB_NAME: ${ssm:/${self:provider.stage}/${self:service}/db/name~true}
RDS_USERNAME: ${ssm:/${self:provider.stage}/${self:service}/db/user~true}
RDS_PASSWORD: ${ssm:/${self:provider.stage}/${self:service}/db/password~true}
SENTRY_DSN: ${ssm:/${self:provider.stage}/${self:service}/sentry/dsn~true}
stackTags:
project: ${self:service}
environment: ${self:provider.stage}
tags:
project: ${self:service}
environment: ${self:provider.stage}
iamRoleStatements:
- Effect: Allow
Action:
- sns:Publish
Resource:
- Ref: SNSTopic
package:
exclude:
- ./**
include:
- ./bin/**
plugins:
- serverless-prune-plugin
custom:
topicName: ${self:service}-${self:provider.stage}-events
AURORA:
DB_NAME: ${ssm:/${self:provider.stage}/${self:service}/db/name~true}
USERNAME: ${ssm:/${self:provider.stage}/${self:service}/db/user~true}
PASSWORD: ${ssm:/${self:provider.stage}/${self:service}/db/password~true}
HOST: ${ssm:/${self:provider.stage}/${self:service}/db/host~true}
PORT: ${ssm:/${self:provider.stage}/${self:service}/db/port~true}
vpc:
securityGroupIds:
- ${ssm:/${self:provider.stage}/${self:service}/vpc/security-group/id~true}
subnetIds:
- ${ssm:/${self:provider.stage}/${self:service}/vpc/subnet/a~true}
- ${ssm:/${self:provider.stage}/${self:service}/vpc/subnet/b~true}
prune:
automatic: true
number: 3
functions:
migrate:
handler: bin/migrate
timeout: 120
environment:
RDS_HOST: ${self:custom.AURORA.HOST}
vpc: ${self:custom.vpc}
query_mentions:
handler: bin/query_mentions
timeout: 120
environment:
SNS_TOPIC_ARN:
Ref: SNSTopic
events:
- schedule: rate(10 minutes)
handle_tweet:
handler: bin/handle_tweet
timeout: 300
environment:
SNS_TOPIC_ARN:
Ref: SNSTopic
RDS_HOST: ${self:custom.AURORA.HOST}
vpc: ${self:custom.vpc}
events:
- sns:
arn:
Ref: SNSTopic
topicName: ${self:custom.topicName}
filterPolicy:
feed:
- handle_tweet
post_tweet:
handler: bin/post_tweet
timeout: 120
environment:
SNS_TOPIC_ARN:
Ref: SNSTopic
events:
- sns:
arn:
Ref: SNSTopic
topicName: ${self:custom.topicName}
filterPolicy:
feed:
- post_tweet
save_bill:
handler: bin/save_bill
timeout: 120
environment:
SNS_TOPIC_ARN:
Ref: SNSTopic
RDS_HOST: ${self:custom.AURORA.HOST}
vpc: ${self:custom.vpc}
events:
- sns:
arn:
Ref: SNSTopic
topicName: ${self:custom.topicName}
filterPolicy:
feed:
- save_bill
query_bills:
handler: bin/query_bills
timeout: 120
environment:
SNS_TOPIC_ARN:
Ref: SNSTopic
RDS_HOST: ${self:custom.AURORA.HOST}
vpc: ${self:custom.vpc}
events:
- schedule: cron(3 2,14,17,20,23 * * ? *)
update_bill:
handler: bin/update_bill
timeout: 120
environment:
SNS_TOPIC_ARN:
Ref: SNSTopic
events:
- sns:
arn:
Ref: SNSTopic
topicName: ${self:custom.topicName}
filterPolicy:
feed:
- update_bill
resources:
Resources:
SNSTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: ${self:service}-${self:provider.stage}-events
DisplayName: ChiBillBotEvents
Tags:
- Key: project
Value: ${self:service}
- Key: environment
Value: ${self:provider.stage}