-
Notifications
You must be signed in to change notification settings - Fork 8
/
serverless.yml
199 lines (187 loc) · 4.57 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
service: bbot
frameworkVersion: ">=1.28.0 <2.0.0"
plugins:
- serverless-domain-manager
- serverless-plugin-tracing
custom:
stage: ${self:provider.stage}
stageConfig: ${file(./serverless_stages.yml):${self:custom.stage}}
customDomain:
domainName: ${self:custom.stageConfig.domainName}
basePath: api
certificateName: ${self:custom.stageConfig.certificateName}
stage: ${self:custom.stage}
createRoute53Record: true
hostedZoneId: Z1EH888BF5XP0N
endpointType: edge
provider:
name: aws
stackName: bbot-${self:provider.stage}
apiName: bbot-${self:provider.stage}
runtime: go1.x
memorySize: 128
stage: ${opt:stage, 'dev'}
region: eu-west-1
endpointType: edge
stackTags:
project: bbot
tags:
project: bbot
tracing: true
iamRoleStatements:
- Effect: "Allow"
Action:
- ssm:GetParameter*
- ssm:DescribeParameters
Resource:
Fn::Join:
- ":"
- - "arn:aws:ssm"
- "Ref" : "AWS::Region"
- "Ref" : "AWS::AccountId"
- "parameter/bbot/${self:custom.stage}/*"
- Effect: "Allow"
Action:
- sqs:SendMessage
Resource:
Fn::GetAtt:
- flagMessageQueue
- Arn
- Effect: "Allow"
Action:
- sqs:SendMessage
Resource:
Fn::GetAtt:
- sendMessageQueue
- Arn
- Effect: "Allow"
Action:
- "dynamodb:GetItem"
- "dynamodb:DeleteItem"
- "dynamodb:PutItem"
- "dynamodb:Scan"
- "dynamodb:Query"
- "dynamodb:UpdateItem"
- "dynamodb:BatchWriteItem"
- "dynamodb:BatchGetItem"
Resource:
Fn::GetAtt:
- tokenTable
- Arn
- Effect: "Allow" #
Action:
- "xray:PutTraceSegments"
- "xray:PutTelemetryRecords"
Resource:
- "*"
package:
exclude:
- ./**
include:
- ./bin/**
- templates/*
functions:
authHandler:
handler: bin/authHandler
events:
- http:
path: auth
method: get
environment:
BUDDYBOT_STAGE: ${self:provider.stage}
BUDDYBOT_AUTH_TABLE:
Ref: tokenTable
BUDDYBOT_REGION:
Ref : "AWS::Region"
actionHandler:
handler: bin/actionHandler
events:
- http:
path: action
method: post
environment:
BUDDYBOT_STAGE: ${self:provider.stage}
SQS_QUEUE_FLAGMESSAGE:
Ref: flagMessageQueue
msgFlagger:
handler: bin/msgFlagger
events:
- sqs:
arn:
Fn::GetAtt:
- flagMessageQueue
- Arn
environment:
BUDDYBOT_STAGE: ${self:provider.stage}
SQS_QUEUE_SENDMESSAGE:
Ref: sendMessageQueue
BUDDYBOT_AUTH_TABLE:
Ref: tokenTable
BUDDYBOT_REGION:
Ref : "AWS::Region"
msgSender:
handler: bin/msgSender
events:
- sqs:
arn:
Fn::GetAtt:
- sendMessageQueue
- Arn
environment:
BUDDYBOT_STAGE: ${self:provider.stage}
BUDDYBOT_AUTH_TABLE:
Ref: tokenTable
BUDDYBOT_REGION:
Ref : "AWS::Region"
resources:
Resources:
flagMessageQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: "bbot-flagMessageQueue-${self:provider.stage}"
MessageRetentionPeriod: 600
Tags:
- Key: "project"
Value: "bbot"
RedrivePolicy:
deadLetterTargetArn:
Fn::GetAtt:
- "deadLetterQueue"
- "Arn"
maxReceiveCount: 2
sendMessageQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: "bbot-sendMessageQueue-${self:provider.stage}"
MessageRetentionPeriod: 600
Tags:
- Key: "project"
Value: "bbot"
RedrivePolicy:
deadLetterTargetArn:
Fn::GetAtt:
- "deadLetterQueue"
- "Arn"
maxReceiveCount: 2
deadLetterQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: "bbot-deadLetterQueue-${self:provider.stage}"
tokenTable:
Type: 'AWS::DynamoDB::Table'
Properties:
TableName: bbot-tokens-${self:provider.stage}
AttributeDefinitions:
- AttributeName: uid
AttributeType: S
KeySchema:
- AttributeName: uid
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
SSESpecification:
SSEEnabled: true
Tags:
- Key: "project"
Value: "bbot"