1
- AWSTemplateFormatVersion : ' 2010-09-09'
1
+ AWSTemplateFormatVersion : " 2010-09-09"
2
2
Transform : AWS::Serverless-2016-10-31
3
3
4
4
Globals :
@@ -18,7 +18,7 @@ Resources:
18
18
- !Ref LogsTrait
19
19
- !Ref ExtensionFn
20
20
- !Ref ExtensionTrait
21
-
21
+
22
22
# Rust function using runtime_fn running on AL1
23
23
RuntimeFn :
24
24
Type : AWS::Serverless::Function
@@ -40,7 +40,7 @@ Resources:
40
40
- !Ref LogsTrait
41
41
- !Ref ExtensionFn
42
42
- !Ref ExtensionTrait
43
-
43
+
44
44
# Rust function using a Service implementation running on AL1
45
45
RuntimeTrait :
46
46
Type : AWS::Serverless::Function
@@ -51,7 +51,7 @@ Resources:
51
51
- !Ref LogsTrait
52
52
- !Ref ExtensionFn
53
53
- !Ref ExtensionTrait
54
-
54
+
55
55
# Rust function using lambda_http::service_fn running on AL2
56
56
HttpFnAl2 :
57
57
Type : AWS::Serverless::Function
@@ -83,7 +83,7 @@ Resources:
83
83
- !Ref LogsTrait
84
84
- !Ref ExtensionFn
85
85
- !Ref ExtensionTrait
86
-
86
+
87
87
# Rust function using lambda_http with Service running on AL2
88
88
HttpTraitAl2 :
89
89
Type : AWS::Serverless::Function
@@ -204,6 +204,93 @@ Resources:
204
204
- !Ref ExtensionFn
205
205
- !Ref ExtensionTrait
206
206
207
+ # Api GW with a binary media type configured
208
+ MediaTypesApi :
209
+ Type : AWS::ApiGateway::RestApi
210
+ Properties :
211
+ Name : !Sub ${AWS::StackName}-responses
212
+ BinaryMediaTypes :
213
+ - " application~1octet-stream"
214
+
215
+ MediaTypesApiDeployment :
216
+ Type : AWS::ApiGateway::Deployment
217
+ DependsOn :
218
+ - TextResourceGet
219
+ - BinaryResourceGet
220
+ Properties :
221
+ RestApiId : !Ref MediaTypesApi
222
+ StageName : Prod
223
+
224
+ TextResource :
225
+ Type : AWS::ApiGateway::Resource
226
+ Properties :
227
+ RestApiId : !Ref MediaTypesApi
228
+ ParentId : !GetAtt ["MediaTypesApi", "RootResourceId"]
229
+ PathPart : text
230
+
231
+ TextResourceGet :
232
+ Type : " AWS::ApiGateway::Method"
233
+ Properties :
234
+ RestApiId : !Ref MediaTypesApi
235
+ ResourceId : !Ref TextResource
236
+ HttpMethod : GET
237
+ AuthorizationType : NONE
238
+ Integration :
239
+ Type : AWS
240
+ IntegrationHttpMethod : POST
241
+ Uri : !Sub >-
242
+ arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${TextFn.Arn}/invocations
243
+
244
+ BinaryResource :
245
+ Type : AWS::ApiGateway::Resource
246
+ Properties :
247
+ RestApiId : !Ref MediaTypesApi
248
+ ParentId : !GetAtt ["MediaTypesApi", "RootResourceId"]
249
+ PathPart : binary
250
+
251
+ BinaryResourceGet :
252
+ Type : " AWS::ApiGateway::Method"
253
+ Properties :
254
+ RestApiId : !Ref MediaTypesApi
255
+ ResourceId : !Ref BinaryResource
256
+ HttpMethod : GET
257
+ AuthorizationType : NONE
258
+ Integration :
259
+ Type : AWS
260
+ IntegrationHttpMethod : POST
261
+ Uri : !Sub >-
262
+ arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${BinaryFn.Arn}/invocations
263
+
264
+ # Rust function using lambda_http with Service testing text responses
265
+ TextFn :
266
+ Type : AWS::Serverless::Function
267
+ Properties :
268
+ CodeUri : ../build/text-fn/
269
+ Runtime : provided
270
+
271
+ TextFnInvokePermission :
272
+ Type : AWS::Lambda::Permission
273
+ Properties :
274
+ FunctionName : !Ref TextFn
275
+ Action : lambda:InvokeFunction
276
+ Principal : apigateway.amazonaws.com
277
+ SourceArn : !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${MediaTypesApi}/*/GET/text
278
+
279
+ # Rust function using lambda_http with Service testing binary responses
280
+ BinaryFn :
281
+ Type : AWS::Serverless::Function
282
+ Properties :
283
+ CodeUri : ../build/binary-fn/
284
+ Runtime : provided
285
+
286
+ BinaryFnInvokePermission :
287
+ Type : AWS::Lambda::Permission
288
+ Properties :
289
+ FunctionName : !Ref BinaryFn
290
+ Action : lambda:InvokeFunction
291
+ Principal : apigateway.amazonaws.com
292
+ SourceArn : !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${MediaTypesApi}/*/GET/binary
293
+
207
294
LogsTrait :
208
295
Type : AWS::Serverless::LayerVersion
209
296
Properties :
@@ -213,7 +300,7 @@ Resources:
213
300
Type : AWS::Serverless::LayerVersion
214
301
Properties :
215
302
ContentUri : ../build/extension-fn/
216
-
303
+
217
304
ExtensionTrait :
218
305
Type : AWS::Serverless::LayerVersion
219
306
Properties :
@@ -236,4 +323,12 @@ Outputs:
236
323
RestApiUrl :
237
324
Value : !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod"
238
325
HttpApiUrl :
239
- Value : !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com"
326
+ Value : !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com"
327
+ MediaTypesApiUrl :
328
+ Value : !Sub "https://${MediaTypesApi}.execute-api.${AWS::Region}.amazonaws.com"
329
+ MediaTypesApi :
330
+ Value : !Ref MediaTypesApi
331
+ TextFnResource :
332
+ Value : !GetAtt ["TextResource", "ResourceId"]
333
+ BinaryFnResource :
334
+ Value : !GetAtt ["BinaryResource", "ResourceId"]
0 commit comments