-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
119 lines (111 loc) · 3.25 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
useDotenv: true
frameworkVersion: "3"
service: ${env:SERVICE_NAME}
provider:
name: aws
region: eu-central-1
runtime: nodejs18.x
stage: ${opt:stage, 'test'}
environment:
DYNAMODB_TABLE: ${self:service}-${sls:stage}
ALLOWED_ORIGINS: ${self:custom.allowedOriginsString.${self:provider.stage}}
iam:
role:
statements:
- Effect: Allow
Action:
- dynamodb:Query
# - dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
# - dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:${aws:region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
plugins:
- serverless-better-credentials
- serverless-plugin-utils
- serverless-esbuild
- serverless-dynamodb
- serverless-domain-manager # Comment out if not using a custom domain
- serverless-offline
custom:
domain:
test: ${env:DOMAIN_TEST}
prod: ${env:DOMAIN_PROD}
allowedOriginsString:
test: ${env:ALLOWED_ORIGINS_TEST}
prod: ${env:ALLOWED_ORIGINS_PROD}
BillingMode:
test: PROVISIONED
prod: PAY_PER_REQUEST
dynamodb:
stages:
- test
start:
port: 8000
inMemory: false
migrate: true
customDomain:
domainName: ${self:custom.domain.${self:provider.stage}}
basePath: 'v1'
createRoute53Record: true
stage: ${self:provider.stage}
certificateName: ${env:CERTIFICATE_NAME}
functions:
create:
handler: storage/create.create
timeout: 30
events:
- http:
path: fingerprint
method: post
cors:
origins: ${split(${self:provider.environment.ALLOWED_ORIGINS}, ',')}
headers:
- Content-Type
allowCredentials: false
get:
handler: storage/get.get
events:
- http:
path: fingerprint/{namespace}/{fingerprint}/{key}
method: get
cors:
origins: ${split(${self:provider.environment.ALLOWED_ORIGINS}, ',')}
headers:
- Content-Type
allowCredentials: false
resources:
Conditions:
IsProvisioned:
Fn::Equals:
- ${self:custom.BillingMode.${self:provider.stage}}
- PROVISIONED
Resources:
ThumbmarkStorageTable:
Type: 'AWS::DynamoDB::Table'
Properties:
# ProvisionedThroughput: # use these three lines when running offline
# ReadCapacityUnits: 1
# WriteCapacityUnits: 1
ProvisionedThroughput:
Fn::If:
- IsProvisioned
- ReadCapacityUnits: 1
WriteCapacityUnits: 1
- Ref: 'AWS::NoValue'
BillingMode: ${self:custom.BillingMode.${self:provider.stage}}
AttributeDefinitions:
- AttributeName: fingerprint
AttributeType: S
- AttributeName: key
AttributeType: S
KeySchema:
- AttributeName: fingerprint
KeyType: HASH
- AttributeName: key
KeyType: RANGE
TableName: ${self:provider.environment.DYNAMODB_TABLE}
TimeToLiveSpecification:
Enabled: true
AttributeName: expiresAt