-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
130 lines (126 loc) · 4.43 KB
/
template.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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
AWS
Sample SAM Template for AWS
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 900
Runtime: python3.7
Resources:
WaiverFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: free_agent_bot/
Handler: app.waiver_check
Layers:
- !Ref ESPNAPILayer
- !Ref PIPLayer
Role: !GetAtt LambdaExecutionRole.Arn
Events:
DailyWaiverCheck:
Type: Schedule
Properties:
# Schedule: rate(10 minutes) # every 10 minutes
Schedule: cron(0 10 * * ? *) # every day at 10 AM UTC
ESPNAPITesterFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: espn-progress-api-tester/
Handler: app.tester
Layers:
- !Ref PIPLayer
Role: !GetAtt LambdaExecutionRole.Arn
# Events:
# DailyWaiverCheck:
# Type: Schedule
# Properties:
# # Schedule: rate(10 minutes) # every 10 minutes
# Schedule: cron(0/10 18-23 ? * 1 *) # Every 5 minutes 6:00PM-8:00PM Sunday UTC (10:00AM-12:00PM PST)
# DailyWaiverCheck2:
# Type: Schedule
# Properties:
# # Schedule: rate(10 minutes) # every 10 minutes
# Schedule: cron(0/10 0-5 ? * 3 *) # Every hour 1AM - 5:30AM UTC (5PM- 9:00PM PST Monday)
ScrambleFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: scramble_bot/
Handler: app.scramble_handler
Layers:
- !Ref ESPNAPILayer
- !Ref PIPLayer
MemorySize: 192
Role: !GetAtt LambdaExecutionRole.Arn
Events:
ThursdayScrambleCheck:
Type: Schedule
Properties:
Schedule: cron(30 5 ? * 6 *) # Friday 5:30 AM PST (Thursday 9:30 PM PST)
SundayScramble1Check:
Type: Schedule
Properties:
Schedule: cron(0/30 18-23 ? * 1 *) # Every hour 6:30PM- midnight Sunday UTC (10:30AM-4:00PM PST)
SundayScramble2Check:
Type: Schedule
Properties:
Schedule: cron(0/30 0-4 ? * 2 *) # Every hour midnight - 5:30 UTC (4PM-9:00PM PST Sunday)
MondayScrambleCheck:
Type: Schedule
Properties:
Schedule: cron(0 0-5 ? * 3 *) # Every hour 1AM - 5:30AM UTC (5PM- 9:00PM PST Monday)
LeagueTable:
Type: AWS::Serverless::SimpleTable
Properties:
PrimaryKey:
Name: league_id
Type: Number
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
ESPNAPILayer:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri: espn-api
LayerName: espn-api-layer
PIPLayer:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri: pip_libraries
LayerName: fantasy-bot-pip-layer
CompatibleRuntimes:
- python3.7
Metadata:
BuildMethod: python3.7
LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/AWSLambdaFullAccess"
AssumeRolePolicyDocument: {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"lambda.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
}
Outputs:
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
WaiverdFunction:
Description: "Function which posts waiver results"
Value: !GetAtt WaiverFunction.Arn
WaiverdFunctionIamRole:
Description: "IAM Role created for Waiver function"
Value: !GetAtt LambdaExecutionRole.Arn