-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yaml
132 lines (124 loc) · 3.78 KB
/
serverless.yaml
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
service: too-good-notify
provider:
name: aws
runtime: python3.10
stage: dev
region: eu-west-3
versionFunctions: false
iam:
role:
statements:
- Effect: Allow
Action:
- lambda:InvokeFunction
- events:PutRule
- events:DeleteRule
- events:ListRules
- events:PutTargets
- events:RemoveTargets
- events:ListTargetsByRule
Resource: "*"
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- "arn:aws:dynamodb:${self:provider.region}:${env:USER_AWS_ACCOUNT_ID}:table/UserNotifications"
- Effect: Allow
Action:
- lambda:GetFunctionConfiguration
- lambda:UpdateFunctionConfiguration
Resource:
- ${env:LAMBDA_MONITORING_ARN}
environment:
SENDER_EMAIL: ${env:SENDER_EMAIL}
SENDER_EMAIL_PASSWORD: ${env:SENDER_EMAIL_PASSWORD}
USER_EMAIL: ${env:USER_EMAIL}
ACCESS_TOKEN: ${env:ACCESS_TOKEN}
REFRESH_TOKEN: ${env:REFRESH_TOKEN}
USER_ID: ${env:USER_ID}
TGTG_COOKIE: ${env:TGTG_COOKIE}
TELEGRAM_BOT_TOKEN: ${env:TELEGRAM_BOT_TOKEN}
TELEGRAM_CHAT_ID: ${env:TELEGRAM_CHAT_ID}
LAMBDA_MONITORING_ARN: ${env:LAMBDA_MONITORING_ARN}
USER_AWS_ACCOUNT_ID: ${env:USER_AWS_ACCOUNT_ID}
COOLDOWN_END_TIME: "" # Leave empty - Managed by the Scheduler class
functions:
tooGoodNotifyScheduler:
name: too-good-notify-scheduler
handler: app.handlers.lambda_scheduler
layers:
- arn:aws:lambda:${self:provider.region}:${env:USER_AWS_ACCOUNT_ID}:layer:TooGoodNotifyLayer:2
events:
- schedule: cron(*/3 10-19 ? * MON-SAT *)
timeout: 5 # seconds
memorySize: 128 # mb
description: Schedule the monitoring of TooGoodToGo items available
tooGoodNotifyMonitoring:
name: too-good-notify-monitoring
handler: app.handlers.tgtg_monitoring_handler
layers:
- arn:aws:lambda:${self:provider.region}:${env:USER_AWS_ACCOUNT_ID}:layer:TooGoodNotifyLayer:2
events:
- eventBridge:
pattern:
source:
- aws.events
detail-type:
- Scheduled Event
timeout: 20 # seconds
memorySize: 256 # mb
description: Monitor new TooGoodToGo items available in my favorite stores
tooGoodNotifyTelegramWebhook:
name: too-good-notify-telegram-webhook
handler: app.handlers.telegram_webhook_handler
layers:
- arn:aws:lambda:${self:provider.region}:${env:USER_AWS_ACCOUNT_ID}:layer:TooGoodNotifyLayer:2
events:
- http:
path: /
method: POST
cors: true
timeout: 30 # seconds
memorySize: 256 # mb
description: Webhook to trigger TooGoodToNotify Telegram Bot
resources:
Resources:
UserNotifications:
Type: AWS::DynamoDB::Table
Properties:
TableName: UserNotifications
AttributeDefinitions:
- AttributeName: storeId
AttributeType: S
- AttributeName: lastNotificationDate
AttributeType: S
KeySchema:
- AttributeName: storeId
KeyType: HASH
- AttributeName: lastNotificationDate
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 10
WriteCapacityUnits: 10
package:
individually: true
exclude:
- node_modules/**
- .vscode/**
- .git/**
- "*.pyc"
- "__pycache__/"
- requirements.txt
plugins:
- serverless-python-requirements
- serverless-dotenv-plugin
custom:
pythonRequirements:
dockerizePip: false
slim: true
noDeploy: ['boto3', 'botocore']