This repository has been archived by the owner on Dec 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
serverless.yml
117 lines (109 loc) · 3.34 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
service: aws-scheduler-v2
provider:
name: aws
runtime: python3.7
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-east-1'}
environment:
STAGE: "${self:provider.stage}"
tags:
department: research
project: aws-scheduler
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:DescribeTable
- dynamodb:DeleteItem
- dynamodb:PutItem
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:GetItem
- dynamodb:GetShardIterator
Resource:
- "${self:custom.table.arn}"
- Effect: Allow
Action:
- lambda:InvokeFunction
Resource: { "Fn::Join": [":", ["arn:aws:lambda:${self:provider.region}", { "Ref": "AWS::AccountId" }, "function", "${self:custom.scheduleFunction}" ] ] }
- Effect: Allow
Action:
- SQS:SendMessage
Resource:
- "${self:custom.queue.arn}"
- Effect: Allow
Action:
- cloudwatch:PutMetricData
Resource: "*"
custom:
# lumigo:
# token: t_e74a5589b5524099bdc04
inbound:
name: "scheduler-input-v2-${self:provider.stage}"
arn: { "Fn::Join": [":", ["arn:aws:sns:${self:provider.region}", { "Ref": "AWS::AccountId" }, "${self:custom.inbound.name}" ] ] }
queue:
name: "scheduler-queue-v2-${self:provider.stage}"
arn: { "Fn::Join": [":", ["arn:aws:sqs:${self:provider.region}", { "Ref": "AWS::AccountId" }, "${self:custom.queue.name}" ] ] }
url: { "Fn::Join": ["/", ["https://sqs.${self:provider.region}.amazonaws.com", { "Ref": "AWS::AccountId" }, "${self:custom.queue.name}" ] ] }
table:
arn: { "Fn::Join": [":", ["arn:aws:dynamodb:${self:provider.region}", { "Ref": "AWS::AccountId" }, "table/aws-scheduler-events-v2-${self:provider.stage}" ] ] }
scheduleFunction: "aws-scheduler-v2-${self:provider.stage}-scheduler"
pythonRequirements:
pythonBin: python3
functions:
consumer:
handler: handler.consumer
events:
- sns:
arn:
Fn::Join:
- ':'
- - 'arn:aws:sns'
- Ref: 'AWS::Region'
- Ref: 'AWS::AccountId'
- "${self:custom.inbound.name}"
topicName: "${self:custom.inbound.name}"
environment:
ENFORCE_USER: true
QUEUE_URL: "${self:custom.queue.url}"
tags:
resource: aws-scheduler-consumer
eventLoader:
handler: handler.event_loader
events:
- schedule: rate(1 minute)
environment:
SCHEDULE_FUNCTION: "${self:custom.scheduleFunction}"
# when we have to wait for DynamoDB autoscaling we may exceed the default of 6s
timeout: 30
tags:
resource: aws-scheduler-event-loader
scheduler:
handler: handler.scheduler
environment:
QUEUE_URL: "${self:custom.queue.url}"
# when we have to wait for DynamoDB autoscaling we may exceed the default of 6s
timeout: 30
tags:
resource: aws-scheduler-scheduler
emitter:
handler: handler.emitter
events:
- sqs:
arn:
Fn::Join:
- ':'
- - arn
- aws
- sqs
- Ref: AWS::Region
- Ref: AWS::AccountId
- "${self:custom.queue.name}"
timeout: 20
tags:
resource: aws-scheduler-emitter
plugins:
- serverless-python-requirements
package:
exclude:
- venv/**
- node_modules/**