-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
131 lines (123 loc) · 3.53 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
service: birthday-bot
frameworkVersion: '3'
resources:
Resources:
BirthdayReminderBotBirthdaysTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: birthday_reminder_bot_birthdays
AttributeDefinitions:
- AttributeName: chat_id
AttributeType: S
- AttributeName: name
AttributeType: S
- AttributeName: birthday_day
AttributeType: N
- AttributeName: birthday_month
AttributeType: N
KeySchema:
- AttributeName: chat_id
KeyType: HASH
- AttributeName: name
KeyType: RANGE
GlobalSecondaryIndexes:
- IndexName: BirthdayIndex
KeySchema:
- AttributeName: birthday_month
KeyType: HASH
- AttributeName: birthday_day
KeyType: RANGE
Projection:
ProjectionType: ALL
- IndexName: UserBirthdaysIndex
KeySchema:
- AttributeName: chat_id
KeyType: HASH
- AttributeName: birthday_month
KeyType: RANGE
Projection:
ProjectionType: ALL
BillingMode: PAY_PER_REQUEST
BirthdayReminderBotUsersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: birthday_reminder_bot_users
AttributeDefinitions:
- AttributeName: chat_id
AttributeType: S
- AttributeName: reminder_hour
AttributeType: N
KeySchema:
- AttributeName: chat_id
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: ReminderHourIndex
KeySchema:
- AttributeName: reminder_hour
KeyType: HASH
Projection:
ProjectionType: ALL
BillingMode: PAY_PER_REQUEST
useDotenv: true
provider:
stage: prod
name: aws
runtime: python3.11
region: sa-east-1
environment:
TOKEN: ${env:TOKEN}
STORAGE_TYPE: DynamoDB
BIRTHDAYS_TABLE_NAME: birthday_reminder_bot_birthdays
USERS_TABLE_NAME: birthday_reminder_bot_users
iam:
role:
statements:
- Effect: "Allow"
Action:
- "dynamodb:GetItem"
- "dynamodb:PutItem"
- "dynamodb:UpdateItem"
- "dynamodb:Scan"
- "dynamodb:DeleteItem"
Resource: "arn:aws:dynamodb:sa-east-1:378764373381:table/birthday_reminder_bot_birthdays"
- Effect: "Allow"
Action:
- "dynamodb:GetItem"
- "dynamodb:PutItem"
- "dynamodb:UpdateItem"
- "dynamodb:Scan"
- "dynamodb:DeleteItem"
Resource: "arn:aws:dynamodb:sa-east-1:378764373381:table/birthday_reminder_bot_users"
package:
patterns:
- '!**'
- 'lambda/**'
- 'src/**'
functions:
birthday_reminder:
handler: lambda.handlers.remind
layers:
- arn:aws:lambda:sa-east-1:378764373381:layer:birthday-bot-prod-python-requirements:2
events:
- schedule:
rate: cron(0 * * * ? *)
birthday_telegram_webhook:
handler: lambda.handlers.webhook
layers:
- arn:aws:lambda:sa-east-1:378764373381:layer:birthday-bot-prod-python-requirements:2
events:
- http:
path: /
method: post
cors: true
plugins:
- serverless-dotenv-plugin
- serverless-python-requirements
custom:
pythonRequirements:
usePoetry: true
slim: true
layer: true
zip: true
noDeploy:
- flask # this is used for the server version