-
Notifications
You must be signed in to change notification settings - Fork 11
/
serverless.yml
111 lines (105 loc) · 3.33 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
service: serverless-postgraphql
provider:
name: aws
runtime: nodejs4.3
# profile: reportingtool
# region: eu-central-1
package:
exclude:
- populateDB/**
functions:
graphql:
handler: handler.graphql
events:
- http:
method: post
path: graphql
integration: lambda
request:
template:
application/json: |
{
"query" : "$util.escapeJavaScript($input.path('$.query'))",
"variables" : $input.json('$.variables'),
"operationName" : "$util.escapeJavaScript($input.path('$.operationName'))",
"headers" : {
#if( $input.params().header.get('Authorization').toString() != "" )
"authorization" : "$input.params().header.get('Authorization')"
#end
}
}
application/graphql: |
{
"query" : "$util.escapeJavaScript($input.body)",
"headers" : {
#if( $input.params().header.get('Authorization').toString() != "" )
"authorization" : "$input.params().header.get('Authorization')"
#end
}
}
- http:
method: get
path: graphql
integration: lambda
request:
parameters:
querystrings:
query: true
variables: false
operationName: false
headers:
Authorization: false
template:
application/json: |
{
"query" : "$util.escapeJavaScript($input.params('query'))",
"variables" : "$util.escapeJavaScript($input.params('variables'))",
"operationName" : "$util.escapeJavaScript($input.params('operationName'))",
"headers" : {
#if( $input.params().header.get('Authorization').toString() != "" )
"authorization" : "$input.params().header.get('Authorization')"
#end
}
}
environment:
PGCON: postgresql://forum_example_postgraphql:xyz@pgEndpoint:5432/forumexample
JWT_SECRET: keyboard_kitten
# For a pgDB inside a VPC look e.g. here:
# http://www.stojanveselinovski.com/blog/2016/01/12/simple-postgresql-rds-cloudformation-template/
resources:
Resources:
pgSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Acess to Postgre
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '5432'
ToPort: '5432'
CidrIp: 0.0.0.0/0
pgDB:
Type: "AWS::RDS::DBInstance"
Properties:
DBName: "forumexample"
AllocatedStorage: 5
DBInstanceClass: "db.t2.micro"
Engine: "postgres"
EngineVersion: "9.5.4"
MasterUsername: "example"
MasterUserPassword: "serverless"
VPCSecurityGroups:
- Fn::GetAtt:
- pgSecurityGroup
- GroupId
Tags:
-
Key: "Name"
Value: "forum_example"
DeletionPolicy: "Snapshot"
Outputs:
pgEndpoint:
Description: "JDBC connection string for database"
Value:
Fn::GetAtt:
- pgDB
- Endpoint.Address