-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
79 lines (75 loc) · 1.97 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
service: serverless-dynamoosejs
provider:
name: aws
runtime: nodejs12.x
region: ap-south-1
environment:
USERS_TABLE_NAME:
Ref: UsersTable
iam:
role:
statements:
- Effect: "Allow"
Action:
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:GetItem
- dynamodb:PutItem
Resource:
- { "Fn::GetAtt": ["UsersTable", "Arn" ] }
- Fn::Join:
- "/"
-
- { "Fn::GetAtt": ["UsersTable", "Arn" ] }
- "index/*"
layers:
dynamoose:
path: layers
description: dynamoose dependency layer for nodejs
compatibleRuntimes:
- nodejs8.10
resources:
Resources:
UsersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.usersTable}
AttributeDefinitions:
- AttributeName: id
AttributeType: N
- AttributeName: dateJoined
AttributeType: N
KeySchema:
- AttributeName: id
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: DateJoinedIndex
KeySchema:
- AttributeName: dateJoined
KeyType: HASH
Projection:
ProjectionType: 'ALL'
BillingMode: PAY_PER_REQUEST
functions:
fetchUserDetails:
handler: src/app.lambda_handler
memorySize: 128
runtime: nodejs18.x
layers:
- !Ref DynamooseLambdaLayer
events:
- http:
path: /service/v1/user/{id}
method: get
documentation:
summary: "Get user details"
description: "Get user details based on userId"
- http:
path: /service/v1/user
method: get
documentation:
summary: "Get users"
description: "Get users based on joining date"
custom:
stage: ${opt:stage, self:provider.stage}
usersTable: ${self:custom.stage}-usersTable