-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate_lambda.yaml
66 lines (66 loc) · 2.02 KB
/
template_lambda.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
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
Timeout: 50
MemorySize: 5000
Api:
OpenApiVersion: 3.0.1
Parameters:
Stage:
Type: String
Default: dev
Resources:
# More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
MyAuthFunctions:
Type: "AWS::Serverless::Function"
Properties:
CodeUri: ./authorizer
Handler: handler.authorize
Runtime: python3.9
MyApi:
Type: "AWS::Serverless::Api"
Properties:
StageName: !Ref Stage
Auth:
DefaultAuthorizer: MyAuthFunctions
Authorizers:
MyAuthFunctions:
FunctionArn: !GetAtt MyAuthFunctions.Arn
FunctionPayloadType: TOKEN
Identity:
# Must specify at least one of
# Headers, QueryStrings, StageVariables, or Context
Headers:
- authorizationToken
ReauthorizeEvery: 100
# More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
PredictFunction:
Type: AWS::Serverless::Function
Properties:
PackageType: Image
Architectures:
- x86_64
Events:
Predict:
Type: Api
Properties:
RestApiId: !Ref MyApi
Path: /predict
Method: POST
Policies:
- AmazonS3FullAccess
Metadata:
Dockerfile: Dockerfile
DockerContext: ./
DockerTag: python3.9-v1
Outputs:
InferenceApi:
Description: "API Gateway endpoint URL for Dev stage for Predict Lambda function"
Value: !Sub "https://${MyApi}.execute-api.${AWS::Region}.amazonaws.com/${Stage}/predict"
InferenceFunction:
Description: "Inference Lambda Function ARN"
Value: !GetAtt PredictFunction.Arn
InferenceFunctionIamRole:
Description: "Implicit IAM Role created for Inference function"
Value: !GetAtt PredictFunction.Arn