-
Notifications
You must be signed in to change notification settings - Fork 20
/
serverless.yml
86 lines (74 loc) · 1.96 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
# This file is the main config file for your service.
#
# For full config options, check the docs:
# docs.serverless.com
service: pytorch-serverless
# You can pin your service to only deploy with a specific Serverless version
frameworkVersion: ">=1.27.1"
provider:
# you can overwrite defaults here
name: aws
runtime: python3.6
stage: dev
region: us-west-2
profile: slsadmin
memorySize: 2048
timeout: 120
# you can define API keys to generate here
apiKeys:
- ${self:service}_default_${self:provider.stage}
# you can define service wide environment variables here
environment:
BUCKET_NAME: pytorch-serverless
STATE_DICT_NAME: dogscats-resnext50.h5
IMAGE_SIZE: 224
IMAGE_STATS: ([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
LABELS_PATH: lib/labels.txt
# you can define custom configuration variables here
variables:
api_version: v0.0.1
# you can add statements to the Lambda function's IAM Role here
iamRoleStatements:
- Effect: Allow
Action:
- s3:ListBucket
Resource: 'arn:aws:s3:::*'
- Effect: Allow
Action:
- s3:GetObject
Resource: 'arn:aws:s3:::*/**'
# you can add packaging information here
package:
exclude:
- package.json
- package-lock.json
- README.md
- node_modules/**
- tests/**
- .DS_Store
- .idea/**
# you can define plugins here
plugins:
- serverless-python-requirements
custom:
pythonRequirements:
dockerizePip: true
zip: true
#
# Define API endpoints
#
functions:
predict:
handler: api/predict.handler
events:
- schedule: rate(15 minutes) # set CloudWatch function to keep lambda warm
- http:
method: GET
cors: true
path: ${self:provider.variables.api_version}/predict
private: true # authorize endpoint with `X-API-KEY` header
request:
parameters:
querystrings:
image_url: true
top_k: false