-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
96 lines (90 loc) · 2.21 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
service: ddns
provider:
name: aws
runtime: rust
memorySize: 512
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-east-1'}
tags:
app: ddns
environment:
USERS_TABLE_NAME: ${self:custom.tableName}
endpointType: REGIONAL
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
Resource:
- 'Fn::Join':
- ':'
- - 'arn:aws:dynamodb'
- Ref: 'AWS::Region'
- Ref: 'AWS::AccountId'
- 'table/${self:custom.tableName}'
- Effect: Allow
Action:
- route53:ChangeResourceRecordSets
Resource:
- arn:aws:route53:::hostedzone/*
- Effect: Allow
Action:
- route53:ListHostedZones
Resource:
- "*"
apiKeys:
- ${opt:stage, 'dev'}-adminKey
custom:
rust:
dockerless: true
tableName: ${self:service}-${opt:stage, 'dev'}-UsersTable
package:
individually: true
plugins:
- serverless-rust
functions:
create_user:
handler: create_user
description: Creates an authorized user to update DNS record
events:
- http:
path: user
method: post
private: true # Requires clients to add API keys values in the `x-api-key` header of their request
request:
headers:
Content-Type: true
schema:
application/json: ${file(requests/create_user.json)}
nic:
handler: nic
description: Update DNS records
events:
- http:
path: nic/update
method: get
request:
headers:
User-Agent: true
Authorization: true
querystrings:
hostname: true
myip: true
resources:
Resources:
UsersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.tableName}
AttributeDefinitions:
- AttributeName: username
AttributeType: S
KeySchema:
- AttributeName: username
KeyType: HASH
BillingMode: PAY_PER_REQUEST
Tags:
- Key: app
Value: ddns
PointInTimeRecoverySpecification:
PointInTimeRecoveryEnabled: false