-
Notifications
You must be signed in to change notification settings - Fork 7
/
serverless.yml
174 lines (165 loc) · 4.53 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
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
164
165
166
167
168
169
170
171
172
173
174
service: duinoapp-server
plugins:
- serverless-iam-roles-per-function
provider:
name: aws
runtime: nodejs12.x
stage: ${file(./sls-config.yml):custom.stage}
region: ${file(./sls-config.yml):custom.region}
profile: ${file(./sls-config.yml):custom.profile}
iam:
role:
statements:
- Effect: "Allow"
Action:
- "elasticfilesystem:ClientMount"
- "elasticfilesystem:ClientWrite"
- "elasticfilesystem:DescribeMountTargets"
Resource: ${file(./sls-config.yml):custom.efsArn}
functions:
app-info:
handler: serverless/handler.server
events:
- schedule: rate(5 minutes) # Keep Warm
- http:
method: GET
path: /version
cors:
origin: '*'
- http:
method: GET
path: /boards
cors:
origin: '*'
- http:
method: GET
path: /libraries
cors:
origin: '*'
- http:
method: GET
path: /v3/info/server
cors:
origin: '*'
- http:
method: GET
path: /v3/info/cores
cors:
origin: '*'
- http:
method: GET
path: /v3/info/boards
cors:
origin: '*'
- http:
method: GET
path: /v3/info/libraries
cors:
origin: '*'
memorySize: 128
timeout: 15
vpc: ${file(./sls-config.yml):custom.vpc}
fileSystemConfig:
arn: ${file(./sls-config.yml):custom.efsArn}
localMountPath: /mnt/duino-data
app-compile:
handler: serverless/handler.server
events:
- schedule: rate(5 minutes) # Keep Warm
- http:
method: POST
path: /compile
cors:
origin: '*'
- http:
method: POST
path: /v3/compile
cors:
origin: '*'
memorySize: 512
timeout: 30
vpc: ${file(./sls-config.yml):custom.vpc}
fileSystemConfig:
arn: ${file(./sls-config.yml):custom.efsArn}
localMountPath: /mnt/duino-data
cache-libs:
handler: serverless/libs.cache
memorySize: 128
timeout: 30
events:
- schedule: rate(5 minutes) # Keep Warm
- http:
method: POST
path: /v3/libraries/cache
cors:
origin: '*'
iamRoleStatementsInherit: true
iamRoleStatements:
- Effect: "Allow"
Action:
- s3:PutObject
- s3:GetObject
Resource: "arn:aws:s3:::${file(./sls-config.yml):custom.s3LibCache}/*"
- Effect: "Allow"
Action:
- lambda:InvokeFunction
- lambda:InvokeAsync
Resource: "arn:aws:lambda:${file(./sls-config.yml):custom.region}:*:function:duinoapp-server-${file(./sls-config.yml):custom.stage}-save-libs"
save-libs:
handler: serverless/libs.save
memorySize: 128
timeout: 15
vpc: ${file(./sls-config.yml):custom.vpc}
fileSystemConfig:
arn: ${file(./sls-config.yml):custom.efsArn}
localMountPath: /mnt/duino-data
iamRoleStatementsInherit: true
iamRoleStatements:
- Effect: "Allow"
Action:
- s3:GetObject
Resource: "arn:aws:s3:::${file(./sls-config.yml):custom.s3LibCache}/*"
install:
handler: serverless/handler.install
memorySize: 2048
timeout: 900
vpc:
securityGroupIds: ${file(./sls-config.yml):custom.vpc.securityGroupIds}
subnetIds:
- ${file(./sls-config.yml):custom.vpc.subnetIds.0}
fileSystemConfig:
arn: ${file(./sls-config.yml):custom.efsArn}
localMountPath: /mnt/duino-data
events:
- schedule: cron(33 0 1 * ? *)
iamRoleStatementsInherit: true
iamRoleStatements:
- Effect: "Allow"
Action:
- cloudformation:CreateStack
- cloudformation:DeleteStack
- cloudformation:DescribeStacks
Resource: "arn:aws:cloudformation:${self:provider.region}:*:*"
- Effect: "Allow"
Action:
- ec2:DescribeAvailabilityZones
- ec2:DescribeAccountAttributes
- ec2:CreateNatGateway
- ec2:DescribeNatGateways
- ec2:DeleteNatGateway
- ec2:CreateRouteTable
- ec2:DescribeRouteTables
- ec2:DeleteRouteTable
- ec2:CreateRoute
- ec2:DescribeRoutes
- ec2:DeleteRoute
- ec2:AllocateAddress
- ec2:DescribeAddresses
- ec2:ReleaseAddress
- ec2:CreateSubnet
- ec2:DescribeSubnets
- ec2:ModifySubnetAttribute
- ec2:DeleteSubnet
- ec2:AssociateRouteTable
- ec2:DisassociateRouteTable
Resource: "*"