-
Notifications
You must be signed in to change notification settings - Fork 1
/
serverless.yml
157 lines (152 loc) · 3.58 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
org: thebeanogamer
app: linkshortener
service: linkshortener
provider:
name: aws
runtime: python3.8
region: ${env:AWS_REGION}
memorySize: 1024
timeout: 6
apiKeys:
- ${opt:stage}-adminkey
environment:
DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}
ADMIN_CONTACT: ${env:ADMIN_CONTACT}
DOMAIN: ${env:DOMAIN}
SES_REGION: ${env:SES_REGION}
FALLBACK_URL: ${env:FALLBACK_URL}
STAGE: ${opt:stage, self:provider.stage}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- "Fn::GetAtt": [ ShortenerDynamoDbTable, Arn ]
- Effect: Allow
Action:
- ses:SendEmail
- ses:SendRawEmail
Resource: arn:aws:ses:${env:SES_REGION}:#{AWS::AccountId}:identity/${env:DOMAIN}
- Effect: Allow
Action:
- ses:SendEmail
- ses:SendRawEmail
Resource: arn:aws:ses:${env:SES_REGION}:#{AWS::AccountId}:identity/${env:ADMIN_CONTACT}
logs:
restApi: true
functions:
fallback:
handler: linkshortener/shortener.fallback
events:
- http:
path: /
method: get
create:
handler: linkshortener/shortener.create
events:
- http:
path: /manage
method: put
private: true
view:
handler: linkshortener/shortener.view
events:
- http:
path: /manage
method: get
private: true
delete:
handler: linkshortener/shortener.delete
events:
- http:
path: /manage
method: delete
private: true
preview:
handler: linkshortener/notifications.view
events:
- http:
path: /email
method: get
private: true
email:
handler: linkshortener/notifications.summary
events:
- http:
path: /email
method: post
private: true
- schedule: rate(24 hours)
robots:
handler: linkshortener/shortener.robots
events:
- http:
path: /robots.txt
method: get
robots:
handler: linkshortener/shortener.humans
events:
- http:
path: /humans.txt
method: get
favicon:
handler: linkshortener/shortener.favicon
events:
- http:
path: /favicon.ico
method: get
shortener:
handler: linkshortener/shortener.shortener
events:
- http:
path: /{id}
method: get
resources:
Resources:
ShortenerDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
AttributeName: code
AttributeType: S
KeySchema:
-
AttributeName: code
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.DYNAMODB_TABLE}
plugins:
- serverless-offline
- serverless-dynamodb-local
- serverless-pseudo-parameters
- serverless-domain-manager
- serverless-python-requirements
- serverless-plugin-tracing
- serverless-ignore
custom:
dynamodb:
stages:
- dev
start:
port: 8000
inMemory: true
heapInitial: 200m
heapMax: 1g
migrate: true
seed: true
convertEmptyValues: true
customDomain:
domainName: ${env:DOMAIN}
basePath: ""
createRoute53Record: true
pythonRequirements:
dockerizePip: non-linux