-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.ts
80 lines (75 loc) · 1.7 KB
/
serverless.ts
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
const env = process.env.APP_ENV || "development";
const defaultHooks = {
"before:package:initialize": [`npm run build:${env}`],
"before:webpack:compile:compile": [`npm run build:${env}`]
};
const plugins = [
"serverless-webpack",
"serverless-offline",
"serverless-hooks-plugin"
];
const getPort = () => {
switch (env) {
case "development":
return 4003;
case "testing":
return 4002;
default:
return 80;
}
};
const config = {
service: "widget-templates",
provider: {
name: "aws",
environment: {
APP_ENV: env
},
stage: '${opt:stage, self:custom.defaultStage}',
iam: '${file(./config/${self:provider.stage}.json):iam}',
region: '${opt:region}',
deploymentBucket: {
name: 'stackla-serverless-${self:provider.stage}-deploys',
maxPreviousDeploymentArtifacts: 10,
blockPublicAccess: true,
skipPolicySetup: true,
versioning: true,
},
},
plugins,
custom: {
defaultStage: 'development',
'serverless-offline': {
httpPort: getPort()
},
esbuild: {
otherExternal: ["hbs"]
},
hooks: process.env.APP_ENV == 'testing' ? [] : defaultHooks
},
package: {
include: ["views/**/*", "dist/**/*", "build/**/*"],
exclude: ["node_modules/**/*"]
},
functions: {
main: {
handler: "./src/functions/main/handler.main",
timeout: 30,
url: {
authorizer: "aws_iam"
},
...(process.env.NODE_ENV === "development" && {
events: [
{
http: {
method: "any",
path: "/{proxy+}"
}
}
]
}),
provisionedConcurrency: 10
}
}
};
module.exports = config;