-
Notifications
You must be signed in to change notification settings - Fork 2
/
serverless.yml
116 lines (111 loc) · 3.49 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
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
# docs.serverless.com
service: soda-carto
provider:
name: aws
runtime: nodejs4.3
environment:
CARTO_DOMAIN: https://phl.carto.com
functions:
soda:
handler: handler.soda
timeout: 30
events:
- http:
path: resource/{resource}
method: get
cors: true
- http:
path: views/{resource}/{format}
method: get
cors: true
- http:
path: api/views/{resource}/{format}
method: get
cors: true
# CloudFormation templates to merge on top of serverless
resources:
Resources:
# Carto API pass-through
ProxyParentResource:
Type: AWS::ApiGateway::Resource
Properties:
ParentId:
Fn::GetAtt:
- ApiGatewayRestApi # serverless default Rest API logical ID
- RootResourceId
PathPart: 'carto'
RestApiId:
Ref: ApiGatewayRestApi
ProxyResource:
Type: AWS::ApiGateway::Resource
Properties:
ParentId:
Ref: ProxyParentResource
PathPart: '{proxy+}' # the endpoint in your API that is set as proxy
RestApiId:
Ref: ApiGatewayRestApi
ProxyMethod:
Type: AWS::ApiGateway::Method
Properties:
ResourceId:
Ref: ProxyResource
RestApiId:
Ref: ApiGatewayRestApi
AuthorizationType: NONE
HttpMethod: GET # the method of your proxy. Is it GET or POST or ... ?
MethodResponses:
- StatusCode: 200
RequestParameters:
method.request.path.proxy: true
Integration:
IntegrationHttpMethod: GET
Type: HTTP_PROXY
Uri: https://phl.carto.com/{proxy} # the URL you want to set a proxy to
IntegrationResponses:
- StatusCode: 200
RequestParameters:
integration.request.path.proxy: method.request.path.proxy
integration.request.header.Accept-Encoding: "'identity'"
PassthroughBehavior: WHEN_NO_MATCH
# VizWit Pages pass-through
VisualizationsProxyParentResource:
Type: AWS::ApiGateway::Resource
Properties:
ParentId:
Fn::GetAtt:
- ApiGatewayRestApi # serverless default Rest API logical ID
- RootResourceId
PathPart: 'visualizations'
RestApiId:
Ref: ApiGatewayRestApi
VisualizationsProxyResource:
Type: AWS::ApiGateway::Resource
Properties:
ParentId:
Ref: VisualizationsProxyParentResource
PathPart: '{proxy+}' # the endpoint in your API that is set as proxy
RestApiId:
Ref: ApiGatewayRestApi
VisualizationsProxyMethod:
Type: AWS::ApiGateway::Method
Properties:
ResourceId:
Ref: VisualizationsProxyResource
RestApiId:
Ref: ApiGatewayRestApi
AuthorizationType: NONE
HttpMethod: GET # the method of your proxy. Is it GET or POST or ... ?
MethodResponses:
- StatusCode: 200
RequestParameters:
method.request.path.proxy: true
Integration:
IntegrationHttpMethod: GET
Type: HTTP_PROXY
Uri: https://cityofphiladelphia.github.io/vizwit-pages/{proxy}/ # the URL you want to set a proxy to
IntegrationResponses:
- StatusCode: 200
RequestParameters:
integration.request.path.proxy: method.request.path.proxy
integration.request.header.Accept-Encoding: "'identity'"
PassthroughBehavior: WHEN_NO_MATCH