-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
100 lines (94 loc) · 2.42 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# "org" ensures this Service is used with the correct Serverless Framework Access Key.
org: vitos
# "app" enables Serverless Framework Dashboard features and sharing them with other Services.
app: indra-challenge
# "service" is the name of this project. This will also be added to your AWS resource names.
service: indra-challenge
plugins:
- serverless-dynamodb
- serverless-auto-swagger
- serverless-offline
custom:
serverless-dynamodb:
stages:
- dev
start:
port: 4566
inMemory: true
migrate: true
autoswagger:
title: 'Indra Challenge docs'
apiType: 'httpApi'
swaggerFiles:
- 'src/features/user/docs/openapi.json'
- 'src/features/swapi/docs/openapi.json'
swaggerPath: 'docs'
basePath: '/api'
schemes: ['https']
stages:
default:
params:
tableName: "users-table-${sls:stage}"
provider:
name: aws
runtime: nodejs20.x
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- Fn::GetAtt: [UsersTable, Arn]
environment:
ENV: ${sls:stage}
USERS_TABLE: ${param:tableName}
resources:
Resources:
UsersTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: userId
AttributeType: S
KeySchema:
- AttributeName: userId
KeyType: HASH
BillingMode: PAY_PER_REQUEST
TableName: ${param:tableName}
functions:
GetSpeciesFromSwapiFunction:
handler: src/features/swapi/handler.getSpecies
events:
- httpApi:
path: /swapi/species
method: get
GetSpecieByIdFromSwapiFunction:
handler: src/features/swapi/handler.getSpecieById
events:
- httpApi:
path: /swapi/species/{specieId}
method: get
GetUsersFunction:
handler: src/features/user/handler.getUsersHandler
events:
- httpApi:
path: /users
method: get
GetUserByIdFunction:
handler: src/features/user/handler.getUserByIdHandler
events:
- httpApi:
path: /users/{userId}
method: get
CreateUserFunction:
handler: src/features/user/handler.createUserHandler
events:
- httpApi:
path: /users
method: post