-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtemplate.yaml
81 lines (79 loc) · 2.3 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
StageName:
Type: String
Default: Prod
Resources:
MyHttpApi:
Type: AWS::Serverless::HttpApi
Properties:
StageName: !Ref StageName
CorsConfiguration:
AllowOrigins:
- '*'
AllowMethods:
- POST
- OPTIONS
AllowHeaders:
- '*'
AllowCredentials: "'true'"
ExposeHeaders: "'*'"
# Add a definition body to handle CORS preflight requests
DefinitionBody:
openapi: 3.0.1
servers:
variables:
stage:
default: !Ref StageName
info:
title: !Sub "${AWS::StackName}"
version: '1.0'
paths:
/answer:
post:
responses:
default:
description: "Default response for POST /answer"
x-amazon-apigateway-integration:
payloadFormatVersion: "2.0"
type: "aws_proxy"
httpMethod: "POST"
uri: !Sub "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${InferenceFunction.Arn}/invocations"
connectionType: "INTERNET"
x-amazon-apigateway-cors:
allowMethods:
- "*"
allowHeaders:
- "*"
exposeHeaders:
- "*"
maxAge: 0
allowCredentials: false
allowOrigins:
- "*"
InferenceFunction:
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:
PackageType: Image
Timeout: 30
MemorySize: 256
Architectures:
- x86_64
Policies:
- AmazonSSMReadOnlyAccess
Events:
Inference:
Type: HttpApi
Properties:
Path: /answer
Method: post
ApiId: !Ref MyHttpApi
Metadata:
Dockerfile: Dockerfile
DockerContext: ./app
DockerTag: python3.9-v1
Outputs:
InferenceApi:
Description: "API Gateway endpoint URL for Prod stage for Inference function"
Value: !Sub "https://${MyHttpApi}.execute-api.${AWS::Region}.amazonaws.com/${StageName}/answer"