File tree 5 files changed +112
-0
lines changed
5 files changed +112
-0
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ Lambda Web Adapter forwards this information to the web applicatioin in a Http H
114
114
- [ Rust Axum in Zip] ( examples/rust-axum-zip )
115
115
- [ Golang Gin] ( examples/gin )
116
116
- [ Golang Gin in Zip] ( examples/gin-zip )
117
+ - [ Deno Oak in Zip] ( examples/deno-zip )
117
118
118
119
## Acknowledgement
119
120
Original file line number Diff line number Diff line change
1
+ # deno-zip
2
+
3
+ This example shows how to deploy a Deno app on Lambda with SnapStart enabled.
4
+
5
+ The Deno app is compiled to a single binary using ` deno compile ` , packaged into Zip file and deployed to Lambda with Web Adapter.
6
+
7
+ We use ` java11 ` runtime to get SnapStart support with one caveat: no runtime hooks.
8
+
9
+ ``` yaml
10
+ DenoFunction :
11
+ Type : AWS::Serverless::Function
12
+ Properties :
13
+ CodeUri : src
14
+ Handler : app
15
+ Runtime : java11
16
+ AutoPublishAlias : live
17
+ SnapStart :
18
+ ApplyOn : PublishedVersions
19
+ Architectures :
20
+ - x86_64
21
+ Layers :
22
+ - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:11
23
+ MemorySize : 512
24
+ Environment :
25
+ Variables :
26
+ AWS_LAMBDA_EXEC_WRAPPER : /opt/bootstrap
27
+ DENO_DIR : /tmp
28
+ PORT : 8000
29
+ Events :
30
+ HelloWorld :
31
+ Type : HttpApi
32
+ Metadata :
33
+ BuildMethod : makefile
34
+ ` ` `
35
+
36
+ ## build and deploy
37
+
38
+ Make sure Deno is already installed. Run the following commands on a x86_64 machine.
39
+
40
+ ` ` ` shell
41
+ sam build
42
+ sam deploy -g
43
+ ```
Original file line number Diff line number Diff line change
1
+ build-DenoFunction :
2
+ deno compile -A -o $(ARTIFACTS_DIR ) /app main.ts
3
+
Original file line number Diff line number Diff line change
1
+ import { Application , Router } from "https://deno.land/x/oak/mod.ts" ;
2
+
3
+ const app = new Application ( ) ;
4
+ const router = new Router ( ) ;
5
+ const port = + ( Deno . env . get ( "PORT" ) || "8080" )
6
+
7
+ router . get ( "/" , ( context ) => {
8
+ context . response . body = {
9
+ success : true ,
10
+ msg : "Hello World" ,
11
+ } ;
12
+ } ) ;
13
+
14
+ app . use ( router . routes ( ) ) ;
15
+
16
+ await app . listen ( { port } ) ;
Original file line number Diff line number Diff line change
1
+ AWSTemplateFormatVersion : ' 2010-09-09'
2
+ Transform : AWS::Serverless-2016-10-31
3
+ Description : >
4
+ deno-zip
5
+
6
+ Sample SAM Template for deno-zip
7
+
8
+ # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
9
+ Globals :
10
+ Function :
11
+ Timeout : 10
12
+ MemorySize : 128
13
+
14
+ Resources :
15
+ DenoFunction :
16
+ Type : AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
17
+ Properties :
18
+ CodeUri : src
19
+ Handler : app
20
+ Runtime : java11
21
+ AutoPublishAlias : live
22
+ SnapStart :
23
+ ApplyOn : PublishedVersions
24
+ Architectures :
25
+ - x86_64
26
+ Layers :
27
+ - !Sub arn:aws:lambda:${AWS::Region}:753240598075:layer:LambdaAdapterLayerX86:11
28
+ MemorySize : 512
29
+ Environment : # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
30
+ Variables :
31
+ AWS_LAMBDA_EXEC_WRAPPER : /opt/bootstrap
32
+ DENO_DIR : /tmp
33
+ PORT : 8000
34
+ Events :
35
+ HelloWorld :
36
+ Type : HttpApi
37
+ Metadata :
38
+ BuildMethod : makefile
39
+
40
+ Outputs :
41
+ DenoFunctionApi :
42
+ Description : " API Gateway endpoint URL for Prod stage for Deno function"
43
+ Value : !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/"
44
+ DenoFunction :
45
+ Description : " Deno Lambda Function ARN"
46
+ Value : !GetAtt DenoFunction.Arn
47
+ DenoFunctionIamRole :
48
+ Description : " Implicit IAM Role created for Deno function"
49
+ Value : !GetAtt DenoFunctionRole.Arn
You can’t perform that action at this time.
0 commit comments