-
Notifications
You must be signed in to change notification settings - Fork 22
/
serverless.yml
194 lines (173 loc) · 4.64 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
service: acg-neptune-db
frameworkVersion: ">2.0.0"
provider:
name: aws
stage: dev
region: us-east-1
resources:
Resources:
# Neptune instances
NeptuneDBCluster:
Type: "AWS::Neptune::DBCluster"
Properties:
DBSubnetGroupName:
Ref: NeptuneDBSubnetGroup
VpcSecurityGroupIds:
- Fn::GetAtt:
- "NeptuneVPC"
- "DefaultSecurityGroup"
- Fn::GetAtt:
- "NeptuneServiceSecurityGroup"
- "GroupId"
Port: 8182
IamAuthEnabled: false # make this true if using this for anything real,
# you will then need to sign requests
DependsOn:
- NeptuneDBSubnetGroup
NeptuneDBInstance:
Type: "AWS::Neptune::DBInstance"
Properties:
DBClusterIdentifier:
Ref: "NeptuneDBCluster"
DBInstanceClass: "db.r4.xlarge"
DependsOn:
- "NeptuneDBCluster"
# VPC network
# VPC containing 2 subnets, these both connect to the IGW which provides public access,
# and are in different availability zones to support the neptune db cluster
NeptuneVPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
Tags:
- Key: Name
Value: neptune-vpc
Subnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId:
Ref: NeptuneVPC
CidrBlock: 10.0.1.0/24
AvailabilityZone:
Fn::Select:
- 0
- Fn::GetAZs: ""
Tags:
- Key: Name
Value: neptune-subnet1
Subnet2:
Type: AWS::EC2::Subnet
Properties:
VpcId:
Ref: NeptuneVPC
CidrBlock: 10.0.2.0/24
AvailabilityZone:
Fn::Select:
- 1
- Fn::GetAZs: ""
Tags:
- Key: Name
Value: neptune-subnet2
NeptuneDBSubnetGroup:
Type: "AWS::Neptune::DBSubnetGroup"
Properties:
DBSubnetGroupDescription: "Neptune DB subnet group"
SubnetIds:
-
Ref: Subnet1
-
Ref: Subnet2
# Setup connectivity by creating an internet gateway
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: neptune-igw
AttachGateway:
Type: "AWS::EC2::VPCGatewayAttachment"
Properties:
InternetGatewayId:
Ref: InternetGateway
VpcId:
Ref: NeptuneVPC
ElasticIP:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
# Create a public routing table that connects the subnets to the IGW
SubnetRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId:
Ref: NeptuneVPC
Tags:
- Key: Name
Value: rt-to-igw
DefaultPublicRoute:
Type: AWS::EC2::Route
Properties:
RouteTableId:
Ref: SubnetRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId:
Ref: InternetGateway
Subnet1RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId:
Ref: SubnetRouteTable
SubnetId:
Ref: Subnet1
Subnet2RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId:
Ref: SubnetRouteTable
SubnetId:
Ref: Subnet2
NeptuneServiceSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: neptune-service-sg
GroupDescription: Allow https to client host
VpcId:
Ref: NeptuneVPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '443'
ToPort: '443'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '8182'
ToPort: '8182'
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: Neptune service security group
Outputs:
# output the values needed by the lambda stack
Subnet1:
Description: Subnet ID 1
Value:
Ref: Subnet1
Subnet2:
Description: Subnet ID 2
Value:
Ref: Subnet2
SecurityGroup:
Description: Security group for the lambda service
Value:
Ref: NeptuneServiceSecurityGroup
DBClusterEndpoint:
Description: Master Endpoint for Neptune Cluster
Value:
Fn::GetAtt:
- "NeptuneDBCluster"
- "Endpoint"
DBClusterResourceId:
Description: Unique identifier needed for IAM policies
Value:
Fn::GetAtt:
- "NeptuneDBCluster"
- "ClusterResourceId"