-
Notifications
You must be signed in to change notification settings - Fork 5
/
serverless.ts
110 lines (108 loc) · 2.35 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
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
import type { Serverless } from "serverless/aws";
const SERVICE_NAME = "brew-book-api";
const DYNAMO_TABLE = `${SERVICE_NAME}-dev`;
const S3_BUCKET = "brew-book";
const serverlessConfiguration: Serverless = {
service: {
name: SERVICE_NAME,
// app and org for use with dashboard.serverless.com
// app: your-app-name,
// org: your-org-name,
},
frameworkVersion: ">=1.72.0",
custom: {
webpack: {
webpackConfig: "./webpack.config.js",
includeModules: true,
},
},
// Add the serverless-webpack plugin
plugins: ["serverless-webpack"],
provider: {
name: "aws",
stage: "dev",
region: "us-east-1",
runtime: "nodejs12.x",
apiGateway: {
minimumCompressionSize: 1024,
},
environment: {
AWS_NODEJS_CONNECTION_REUSE_ENABLED: "1",
DYNAMO_TABLE,
S3_BUCKET,
},
iamRoleStatements: [
{
Effect: "Allow",
Action: [
"dynamodb:Query",
"dynamodb:Scan",
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem",
],
Resource: "*",
},
{
Effect: "Allow",
Action: ["s3:PutObject", "s3:GetObject"],
Resource: `arn:aws:s3:::${S3_BUCKET}/*`,
},
],
},
functions: {
save: {
handler: "handler.saveBrew",
events: [
{
http: {
method: "post",
path: "save",
cors: true,
},
},
],
},
brews: {
handler: "handler.getBrews",
events: [
{
http: {
method: "get",
path: "brews",
cors: true,
},
},
],
},
},
resources: {
Resources: {
BrewsDynamoTable: {
Type: "AWS::DynamoDB::Table",
DeletionPolicy: "Retain",
Properties: {
AttributeDefinitions: [
{
AttributeName: "id",
AttributeType: "S",
},
],
KeySchema: [
{
AttributeName: "id",
KeyType: "HASH",
},
],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1,
},
TableName: DYNAMO_TABLE,
},
},
},
},
};
module.exports = serverlessConfiguration;