-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.yml
More file actions
98 lines (93 loc) · 2.26 KB
/
serverless.yml
File metadata and controls
98 lines (93 loc) · 2.26 KB
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
org: mateusilvadev
service: live060
provider:
name: aws
region: sa-east-1
runtime: nodejs20.x
architecture: arm64
environment:
PRODUCTS_TABLE: !Ref ProductsTable
PRODUCTS_TABLE_STREAM: !GetAtt ProductsTable.StreamArn
ALGOLIA_APP_ID: ${env:ALGOLIA_APP_ID}
ALGOLIA_API_KEY: ${env:ALGOLIA_API_KEY}
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: !GetAtt ProductsTable.Arn
package:
individually: true
build:
esbuild:
bundle: true
minify: true
sourcemap: false
exclude:
- '@aws-sdk/*'
functions:
createProduct:
handler: src/functions/createProduct.handler
events:
- httpApi:
method: POST
path: /products
updateProduct:
handler: src/functions/updateProduct.handler
events:
- httpApi:
method: PUT
path: /products/{productId}
deleteProduct:
handler: src/functions/deleteProduct.handler
events:
- httpApi:
method: DELETE
path: /products/{productId}
getShards:
handler: src/functions/getShards.handler
events:
- httpApi:
method: GET
path: /shards
processDDBStream:
handler: src/functions/processDDBStream.handler
events:
- stream:
type: dynamodb
arn: !GetAtt ProductsTable.StreamArn
batchSize: 5
maximumRetryAttempts: 2
destinations:
onFailure:
type: sqs
arn: !GetAtt DDBStreamsDLQ.Arn
search:
handler: src/functions/search.handler
events:
- httpApi:
method: GET
path: /search
resources:
Resources:
ProductsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ProductsTable
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
DDBStreamsDLQ:
Type: AWS::SQS::Queue
Properties:
QueueName: DDBStreamsDLQ
MessageRetentionPeriod: 1209600 # 14 days