-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
73 lines (64 loc) · 1.63 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
service: megabus-demand-analysis
provider:
name: aws
runtime: python3.7
region: us-east-1
iamRoleStatements:
- Effect: "Allow"
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
Fn::GetAtt:
- journeysTable
- Arn
- Effect: "Allow"
Action:
- "sns:Publish"
Resource: "arn:aws:sns:${self:provider.region}:${self:provider.environment.AWS_ACCOUNT_ID}:scrape-parameters"
environment:
AWS_ACCOUNT_ID: ${file(./vars.yml):AWS_ACCOUNT_ID}
REGION: ${self:provider.region}
SENTRY_KEY: ${file(./vars.yml):SENTRY_KEY}
SENTRY_PROJECT: ${file(./vars.yml):SENTRY_PROJECT}
functions:
scrape_megabus:
handler: handler.scrape_megabus
timeout: 70
events:
- sns: scrape-parameters
trigger_scrape_megabus:
handler: handler.trigger_scrape_megabus
timeout: 60
events:
- schedule: rate(2 hours)
journey_data:
handler: handler.get_journey_data
events:
- http:
path: journey
method: GET
plugins:
- serverless-python-requirements
custom:
pythonRequirements:
dockerizePip: false
resources:
Resources:
journeysTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: journeysTable
AttributeDefinitions:
- AttributeName: journey_id
AttributeType: S
KeySchema:
- AttributeName: journey_id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1