-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yaml
More file actions
163 lines (151 loc) · 4.8 KB
/
template.yaml
File metadata and controls
163 lines (151 loc) · 4.8 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: 'Smalruby Infrastructure - API Gateway and Lambda functions for CORS proxy and Scratch API proxy'
Globals:
Function:
Timeout: 10
MemorySize: 128
Architectures:
- arm64
Parameters:
Stage:
Type: String
Default: prod
Description: Deployment stage
DomainName:
Type: String
Default: api.smalruby.app
Description: Custom domain name for API Gateway
Resources:
# Lambda Functions
SmalrubyCorsProxyFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: smalruby-cors-proxy
Runtime: ruby3.3
Handler: lambda_function.lambda_handler
CodeUri: lambda/smalruby-cors-proxy/
Description: General-purpose CORS proxy for Smalruby
MemorySize: 512
Events:
CorsProxyGet:
Type: Api
Properties:
RestApiId: !Ref SmalrubyApiGateway
Path: /cors-proxy
Method: GET
SmalrubyMeshZoneGetFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: smalruby-mesh-zone-get
Runtime: ruby3.3
Handler: lambda_function.lambda_handler
CodeUri: lambda/smalruby-mesh-zone-get/
Description: Generate identity from gateway IPv4 address for Smalruby Mesh
Events:
MeshDomainGet:
Type: Api
Properties:
RestApiId: !Ref SmalrubyApiGateway
Path: /mesh-domain
Method: GET
SmalrubyTranslateProxyFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: smalruby-scratch-api-proxy-translate
Runtime: ruby3.3
Handler: lambda_function.lambda_handler
CodeUri: lambda/smalruby-scratch-api-proxy-translate/
Description: Scratch API proxy for translate endpoint
Events:
TranslateGet:
Type: Api
Properties:
RestApiId: !Ref SmalrubyApiGateway
Path: /scratch-api-proxy/translate
Method: GET
SmalrubyGetProjectInfoFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: smalruby-scratch-api-proxy-get-project-info
Runtime: ruby3.3
Handler: lambda_function.lambda_handler
CodeUri: lambda/smalruby-scratch-api-proxy-get-project-info/
Description: Scratch API proxy for project info endpoint
Events:
ProjectInfoGet:
Type: Api
Properties:
RestApiId: !Ref SmalrubyApiGateway
Path: /scratch-api-proxy/projects/{projectId}
Method: GET
CorsForSmalrubyFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: cors-for-smalruby
Runtime: ruby3.3
Handler: lambda_function.lambda_handler
CodeUri: lambda/cors-for-smalruby/
Description: CORS handler for Smalruby
Events:
CorsProxyOptions:
Type: Api
Properties:
RestApiId: !Ref SmalrubyApiGateway
Path: /cors-proxy
Method: OPTIONS
MeshDomainOptions:
Type: Api
Properties:
RestApiId: !Ref SmalrubyApiGateway
Path: /mesh-domain
Method: OPTIONS
TranslateOptions:
Type: Api
Properties:
RestApiId: !Ref SmalrubyApiGateway
Path: /scratch-api-proxy/translate
Method: OPTIONS
ProjectInfoOptions:
Type: Api
Properties:
RestApiId: !Ref SmalrubyApiGateway
Path: /scratch-api-proxy/projects/{projectId}
Method: OPTIONS
# API Gateway
SmalrubyApiGateway:
Type: AWS::Serverless::Api
Properties:
Name: Smalruby Mesh Zone
Description: Generate identity from the gateway IPv4 address for Smalruby Mesh
StageName: !Ref Stage
EndpointConfiguration:
Type: REGIONAL
BinaryMediaTypes:
- "*/*"
Cors:
AllowMethods: "'GET,POST,OPTIONS'"
AllowHeaders: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
AllowOrigin: "'*'"
MaxAge: "'600'"
Outputs:
ApiUrl:
Description: "API Gateway endpoint URL"
Value: !Sub "https://${SmalrubyApiGateway}.execute-api.${AWS::Region}.amazonaws.com/${Stage}/"
Export:
Name: !Sub "${AWS::StackName}-ApiUrl"
ApiGatewayId:
Description: "API Gateway ID"
Value: !Ref SmalrubyApiGateway
Export:
Name: !Sub "${AWS::StackName}-ApiGatewayId"
CorsProxyFunctionArn:
Description: "CORS Proxy Lambda Function ARN"
Value: !GetAtt SmalrubyCorsProxyFunction.Arn
Export:
Name: !Sub "${AWS::StackName}-CorsProxyFunctionArn"
MeshZoneGetFunctionArn:
Description: "Mesh Zone Get Lambda Function ARN"
Value: !GetAtt SmalrubyMeshZoneGetFunction.Arn
Export:
Name: !Sub "${AWS::StackName}-MeshZoneGetFunctionArn"