/
serverless.yml
112 lines (106 loc) · 2.52 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
service: sls-go-bot
frameworkVersion: ">=1.28.0 <2.0.0"
provider:
name: aws
runtime: go1.x
iamRoleStatements:
- Effect: "Allow"
Action:
- "dynamodb:PutItem"
- "dynamodb:Query"
- "dynamodb:DeleteItem"
- "dynamodb:GetItem"
- "dynamodb:UpdateItem"
Resource:
- Fn::GetAtt:
- usersTable
- Arn
- Effect: "Allow"
Action:
- "sqs:DeleteMessage"
- "sqs:ReceiveMessage"
- "sqs:SendMessage"
Resource:
- Fn::GetAtt:
- deleteMsg
- Arn
- Effect: "Allow"
Action:
- "sqs:DeleteMessage"
- "sqs:ReceiveMessage"
- "sqs:SendMessage"
Resource:
- Fn::GetAtt:
- captchaCountDown
- Arn
stage: ${opt:stage, 'dev'}
environment:
BOT_TOKEN: ${file(config.${self:provider.stage}.yml):BOT_TOKEN}
DELETE_MSG_QUEUE:
Ref: deleteMsg
CAPTCHA_COUNTDOWN_QUEUE:
Ref: captchaCountDown
USERS_TABLE_NAME: ${self:resources.Resources.usersTable.Properties.TableName}
package:
exclude:
- .serverless
- cmd/**
- layer/**
- pkg/**
- \*.yml
functions:
bot:
handler: bin/bot
layers:
- {Ref: StaticLambdaLayer}
events:
- http: ANY {proxy+}
- http: ANY /
deleteMsg:
handler: bin/delete-msg
events:
- sqs:
arn:
Fn::GetAtt:
- deleteMsg
- Arn
captchaCountDown:
handler: bin/captcha-count-down
events:
- sqs:
arn:
Fn::GetAtt:
- captchaCountDown
- Arn
layers:
static:
path: layer
resources:
Resources:
deleteMsg:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:service}-${self:provider.stage}-delete-msg
VisibilityTimeout: 10
captchaCountDown:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:service}-${self:provider.stage}-captcha-count-down
VisibilityTimeout: 10
usersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:service}-${self:provider.stage}-black-list
AttributeDefinitions:
- AttributeName: chatID
AttributeType: N
- AttributeName: userID
AttributeType: N
KeySchema:
- AttributeName: chatID
KeyType: HASH
- AttributeName: userID
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1