-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
80 lines (71 loc) · 1.79 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
service: serverless-music-gear
frameworkVersion: "3"
provider:
name: aws
runtime: nodejs18.x
region: us-east-1
environment:
DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}
# Powertools setup
POWERTOOLS_SERVICE_NAME: ${self:service}
POWERTOOLS_METRICS_NAMESPACE: ${self:service}
# Enable X-Ray tracing for both APIGW and Lambda
tracing:
lambda: true
apiGateway: true
# Read/write permissions for functions to DDB
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
# Function definitions with event sources
functions:
create:
handler: src/handlers/api/rentals.create
events:
- http:
path: rentals
method: post
cors: true
list:
handler: src/handlers/api/rentals.list
events:
- http:
path: rentals
method: get
cors: true
get:
handler: src/handlers/api/rentals.get
events:
- http:
path: rentals/{id}
method: get
cors: true
update:
handler: src/handlers/api/rentals.update
events:
- http:
path: rentals/{id}
method: put
cors: true
delete:
handler: src/handlers/api/rentals.remove
events:
- http:
path: rentals/{id}
method: delete
cors: true
# External files for CFN resources
resources:
Resources: ${file(./resources/database.yml)}
# Optimize bundle sizes with esbuild
plugins:
- serverless-esbuild