-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.yml
More file actions
93 lines (86 loc) · 2.48 KB
/
Copy pathserverless.yml
File metadata and controls
93 lines (86 loc) · 2.48 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
service: userserviceHandler
frameworkVersion: '3'
provider:
name: aws
runtime: nodejs18.x
stage: ${opt:stage, 'dev'}
region: enter region
memorySize: 512
timeout: 10
environment:
USERS_TABLE: ${self:custom.${self:provider.stage}.userTableName}
plugins:
- serverless-offline
custom:
DB_ADMIN_SM: database name
dev:
userTableName: usersTable
SENDMESSAGEFUNCTION: lambda function name
functions:
user:
handler: src/service/user.createUser
name: createUser-${self:provider.stage}
description: "creates new user"
environment:
SENDMESSAGEFUNC: ${self:custom.${self:provider.stage}.SENDMESSAGEFUNCTION}
events:
- httpApi:
path: /user
method: post
getuser:
handler: src/service/user.getUser
description: "get new user"
events:
- httpApi:
path: /getuser
method: get
getUserbyCountryandCreatedAt:
handler: src/service/user.getUserbyCountryandCreatedAt
description: "search user"
environment:
TEST_VAR_FS: "TEST_VAR_FS_VALUE"
events:
- httpApi:
path: /getUserbyCountryandCreatedAt
method: post
getUserbyCountryandCreatedAtScan:
handler: src/service/user.getUserbyCountryandCreatedAtScan
description: "scan by user cond"
environment:
TEST_VAR_FS: "TEST_VAR_FS_VALUE"
events:
- httpApi:
path: /getUserbyCountryandCreatedAtScan
method: post
resources:
Resources:
UsersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.${self:provider.stage}.userTableName}
AttributeDefinitions:
- AttributeName: Email
AttributeType: S
- AttributeName: Country
AttributeType: S
- AttributeName: CreatedAt
AttributeType: S
KeySchema:
- AttributeName: Email
KeyType: HASH # Partition key
BillingMode: PROVISIONED
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 10
GlobalSecondaryIndexes:
- IndexName: createdAtIndex # Fixed typo in index name
KeySchema:
- AttributeName: Country
KeyType: HASH # Partition key for GSI
- AttributeName: CreatedAt
KeyType: RANGE # Sort key for GSI
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 10