-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
102 lines (92 loc) · 2.29 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
service: ping
provider:
name: aws
runtime: nodejs8.10
region: eu-central-1
stage: ${opt:stage, 'dev'}
environment:
SERVER_URL: ${file(./env/${self:provider.stage}.json):serverUrl}
PG_USER: ${env:PG_USER}
PG_PW: ${env:PG_PW}
PG_DB: ${env:PG_DB}
PG_ENDPOINT:
Fn::GetAtt:
- pgDB
- Endpoint.Address
functions:
auth:
handler: lambdas/auth.handler
cors: true
pingServices:
handler: lambdas/pingServices.handler
events:
- schedule: rate(1 minute)
getPings:
handler: lambdas/getPings.handler
events:
- http:
path: getPings
method: get
authorizer: auth
cors: true
addEndpoint:
handler: lambdas/addEndpoint.handler
events:
- http:
path: addEndpoint
method: post
authorizer: auth
cors: true
getEndpoints:
handler: lambdas/getEndpoints.handler
events:
- http:
path: getEndpoints
method: get
authorizer: auth
cors: true
deleteEndpoint:
handler: lambdas/deleteEndpoint.handler
events:
- http:
path: deleteEndpoint
method: delete
authorizer: auth
cors: true
resources:
Resources:
GatewayResponseDefault4XX:
Type: 'AWS::ApiGateway::GatewayResponse'
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
ResponseType: DEFAULT_4XX
RestApiId:
Ref: 'ApiGatewayRestApi'
pgSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Access to Postgres
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '5432'
ToPort: '5432'
CidrIp: 0.0.0.0/0
pgDB:
Type: "AWS::RDS::DBInstance"
Properties:
DBName: ${env:PG_DB}
AllocatedStorage: 5
DBInstanceClass: "db.t2.micro"
Engine: "postgres"
EngineVersion: "10.4"
MasterUsername: ${env:PG_USER}
MasterUserPassword: ${env:PG_PW}
VPCSecurityGroups:
- Fn::GetAtt:
- pgSecurityGroup
- GroupId
DeletionPolicy: "Snapshot"
plugins:
- serverless-offline