-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
109 lines (106 loc) · 2.61 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
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
MemorySize: 128
Timeout: 3
Tracing: Active
Resources:
ResourceGroup:
Type: AWS::ResourceGroups::Group
Properties:
Name:
Ref: AWS::StackName
GinFunction:
Type: AWS::Serverless::Function
Properties:
AutoPublishAlias: live
Runtime: go1.x
Handler: main
Events:
ProxyApi:
Type: Api
Properties:
Path: /gin/{proxy+}
Method: ANY
Metadata:
BuildMethod: makefile
EchoFunction:
Type: AWS::Serverless::Function
Properties:
AutoPublishAlias: live
Runtime: go1.x
Handler: main
Events:
ProxyApi:
Type: Api
Properties:
Path: /echo/{proxy+}
Method: ANY
Metadata:
BuildMethod: makefile
PythonCommonLayerA:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri: layers/python-common-a
CompatibleRuntimes:
- python3.9
Metadata:
BuildMethod: python3.9
PythonCommonLayerB:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri: .
CompatibleRuntimes:
- python3.9
Metadata:
BuildMethod: makefile
PythonInlineFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: python3.9
Layers:
- Ref: PythonCommonLayerA
- Ref: PythonCommonLayerB
InlineCode: |
import common_a
import common_b
def handler(event, context):
# call common_a layer
print(common_a.say_hello())
print(common_a.call_echo())
# call common_b layer
print(common_b.say_hello())
NodejsCommonLayer:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri: layers/nodejs-common
CompatibleRuntimes:
- nodejs16.x
Metadata:
BuildMethod: nodejs16.x
NodejsInlineFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs16.x
Layers:
- Ref: NodejsCommonLayer
Environment:
Variables:
DEBUG: "*"
InlineCode: |
const debug = require('debug')('lambda')
module.exports = {
async handler(event) {
debug(JSON.stringify(event, null, 2))
}
}
Outputs:
ApiUrl:
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod"
PythonFunctionArn:
Value: !GetAtt PythonInlineFunction.Arn
NodejsFunctionArn:
Value: !GetAtt NodejsInlineFunction.Arn