forked from amcp/dynamodb-janusgraph-storage-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dynamodb-janusgraph-storage-backend-cfn.yaml
579 lines (579 loc) · 14.4 KB
/
dynamodb-janusgraph-storage-backend-cfn.yaml
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
---
Description: This stack creates a VPC, an EC2 Amazon Linux host in the VPC with a
Public IP, and deploys Gremlin Server on it. **WARNING** This template creates
an Amazon EC2 instance. You will be billed for the AWS resources used if you
create a stack from this template.
AWSTemplateFormatVersion: '2010-09-09'
Mappings:
AWSRegionArch2AMI:
ap-south-1:
HVMG2: ami-52c7b43d
HVM64: ami-f5c6b59a
eu-west-2:
HVMG2: ami-b6daced2
HVM64: ami-b7daced3
eu-west-1:
HVMG2: ami-01ccc867
PV64: ami-d1c0c4b7
HVM64: ami-d3c0c4b5
ap-northeast-2:
HVM64: ami-9a15c7f4
HVMG2: ami-9d15c7f3
ap-northeast-1:
PV64: ami-30391657
HVM64: ami-6a3b140d
HVMG2: ami-923d12f5
sa-east-1:
HVM64: ami-2bccae47
PV64: ami-36cfad5a
HVMG2: ami-37cfad5b
ca-central-1:
HVMG2: ami-0bd66a6f
HVM64: ami-73d06c17
ap-southeast-1:
PV64: ami-ab5ce5c8
HVM64: ami-b65de4d5
HVMG2: ami-fc5ae39f
ap-southeast-2:
HVMG2: ami-162c2575
HVM64: ami-762a2315
PV64: ami-af2128cc
eu-central-1:
HVM64: ami-506fbd3f
HVMG2: ami-b968bad6
PV64: ami-ba68bad5
us-east-1:
PV64: ami-668f1e70
HVMG2: ami-c58c1dd3
HVM64: ami-fd8617eb
us-east-2:
HVMG2: ami-4191b524
HVM64: ami-6693b703
us-west-1:
PV64: ami-0f85a06f
HVMG2: ami-7a85a01a
HVM64: ami-f887a298
us-west-2:
HVM64: ami-3234a652
HVMG2: ami-4836a428
PV64: ami-c737a5a7
AWSInstanceType2Arch:
t2.nano:
Arch: HVM64
t2.micro:
Arch: HVM64
t2.small:
Arch: HVM64
t2.medium:
Arch: HVM64
t2.large:
Arch: HVM64
t2.xlarge:
Arch: HVM64
t2.2xlarge:
Arch: HVM64
m4.large:
Arch: HVM64
m4.xlarge:
Arch: HVM64
m4.2xlarge:
Arch: HVM64
m4.4xlarge:
Arch: HVM64
m4.10xlarge:
Arch: HVM64
m4.16xlarge:
Arch: HVM64
m3.medium:
Arch: HVM64
m3.large:
Arch: HVM64
m3.xlarge:
Arch: HVM64
m3.2xlarge:
Arch: HVM64
c4.large:
Arch: HVM64
c4.xlarge:
Arch: HVM64
c4.2xlarge:
Arch: HVM64
c4.4xlarge:
Arch: HVM64
c4.8xlarge:
Arch: HVM64
c3.large:
Arch: HVM64
c3.xlarge:
Arch: HVM64
c3.2xlarge:
Arch: HVM64
c3.4xlarge:
Arch: HVM64
c3.8xlarge:
Arch: HVM64
r3.large:
Arch: HVM64
r3.xlarge:
Arch: HVM64
r3.2xlarge:
Arch: HVM64
r3.4xlarge:
Arch: HVM64
r3.8xlarge:
Arch: HVM64
r4.large:
Arch: HVM64
r4.xlarge:
Arch: HVM64
r4.2xlarge:
Arch: HVM64
r4.4xlarge:
Arch: HVM64
r4.8xlarge:
Arch: HVM64
r4.16xlarge:
Arch: HVM64
x1.16xlarge:
Arch: HVM64
x1.32xlarge:
Arch: HVM64
d2.xlarge:
Arch: HVM64
d2.2xlarge:
Arch: HVM64
d2.4xlarge:
Arch: HVM64
d2.8xlarge:
Arch: HVM64
i2.xlarge:
Arch: HVM64
i2.2xlarge:
Arch: HVM64
i2.4xlarge:
Arch: HVM64
i2.8xlarge:
Arch: HVM64
i3.large:
Arch: HVM64
i3.xlarge:
Arch: HVM64
i3.2xlarge:
Arch: HVM64
i3.4xlarge:
Arch: HVM64
i3.8xlarge:
Arch: HVM64
i3.16xlarge:
Arch: HVM64
f1.2xlarge:
Arch: HVM64
f1.16xlarge:
Arch: HVM64
p2.xlarge:
Arch: HVM64
p2.8xlarge:
Arch: HVM64
p2.16xlarge:
Arch: HVM64
g2.2xlarge:
Arch: HVMG2
g2.8xlarge:
Arch: HVMG2
Parameters:
InstanceType:
Description: EC2 instance type
Type: String
Default: m4.10xlarge
AllowedValues:
- t2.nano
- t2.micro
- t2.small
- t2.medium
- t2.large
- t2.xlarge
- t2.2xlarge
- m4.large
- m4.xlarge
- m4.2xlarge
- m4.4xlarge
- m4.10xlarge
- m4.16xlarge
- m3.medium
- m3.large
- m3.xlarge
- m3.2xlarge
- c4.large
- c4.xlarge
- c4.2xlarge
- c4.4xlarge
- c4.8xlarge
- c3.large
- c3.xlarge
- c3.2xlarge
- c3.4xlarge
- c3.8xlarge
- r3.large
- r3.xlarge
- r3.2xlarge
- r3.4xlarge
- r3.8xlarge
- r4.large
- r4.xlarge
- r4.2xlarge
- r4.4xlarge
- r4.8xlarge
- r4.16xlarge
- x1.16xlarge
- x1.32xlarge
- d2.xlarge
- d2.2xlarge
- d2.4xlarge
- d2.8xlarge
- i2.xlarge
- i2.2xlarge
- i2.4xlarge
- i2.8xlarge
- i3.large
- i3.xlarge
- i3.2xlarge
- i3.4xlarge
- i3.8xlarge
- i3.16xlarge
- f1.2xlarge
- f1.16xlarge
- p2.xlarge
- p2.8xlarge
- p2.16xlarge
- g2.2xlarge
- g2.8xlarge
ConstraintDescription: Must be a valid EC2 instance type.
KeyName:
Description: Name of existing EC2 SSH key
Type: AWS::EC2::KeyPair::KeyName
Default: ''
MinLength: '0'
MaxLength: '255'
AllowedPattern: "[\\x20-\\x7E]*"
ConstraintDescription: can contain only ASCII characters.
SSHLocation:
Description: CIDR range allowed to SSH into EC2 instance
Type: String
MinLength: '9'
MaxLength: '18'
Default: 0.0.0.0/32
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
VPCRange:
Description: CIDR range to assign to new VPC
Type: String
MinLength: '9'
MaxLength: '18'
Default: 10.0.0.0/16
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
SubnetRange:
Description: CIDR range to assign to new subnet in VPC
Type: String
MinLength: '9'
MaxLength: '18'
Default: 10.0.0.0/24
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
GremlinServerPort:
Description: The port to serve Gremlin Server Websockets API out of
Type: String
MinLength: '1'
MaxLength: '5'
Default: '8182'
AllowedPattern: "(\\d{1,5})"
ConstraintDescription: must be a valid port.
StorageBackendPropertiesFileS3Url:
Description: S3 URL to the JanusGraph configuration file
Type: String
MinLength: '1'
JanusGraphInstanceProfilePath:
Description: The IAM path
Type: String
Default: "/"
MinLength: '1'
JanusGraphInstanceProfileRole:
Description: An IAM role that includes at least S3 read and DynamoDB full access
Type: String
MinLength: '1'
Resources:
InstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Path:
Ref: JanusGraphInstanceProfilePath
Roles:
- Ref: JanusGraphInstanceProfileRole
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock:
Ref: VPCRange
EnableDnsSupport: 'true'
EnableDnsHostnames: 'true'
Tags:
- Key: Application
Value:
Ref: AWS::StackId
Subnet:
Type: AWS::EC2::Subnet
Properties:
VpcId:
Ref: VPC
CidrBlock:
Ref: SubnetRange
Tags:
- Key: Application
Value:
Ref: AWS::StackId
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Application
Value:
Ref: AWS::StackId
AttachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId:
Ref: VPC
InternetGatewayId:
Ref: InternetGateway
RouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId:
Ref: VPC
Tags:
- Key: Application
Value:
Ref: AWS::StackId
Route:
Type: AWS::EC2::Route
DependsOn: AttachGateway
Properties:
RouteTableId:
Ref: RouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId:
Ref: InternetGateway
SubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId:
Ref: Subnet
RouteTableId:
Ref: RouteTable
NetworkAcl:
Type: AWS::EC2::NetworkAcl
Properties:
VpcId:
Ref: VPC
Tags:
- Key: Application
Value:
Ref: AWS::StackId
InboundSSHNetworkAclEntry:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId:
Ref: NetworkAcl
RuleNumber: '101'
Protocol: '6'
RuleAction: allow
Egress: 'false'
CidrBlock:
Ref: SSHLocation
PortRange:
From: '22'
To: '22'
InboundResponsePortsNetworkAclEntry:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId:
Ref: NetworkAcl
RuleNumber: '102'
Protocol: '6'
RuleAction: allow
Egress: 'false'
CidrBlock: 0.0.0.0/0
PortRange:
From: '1024'
To: '65535'
OutboundHTTPNetworkAclEntry:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId:
Ref: NetworkAcl
RuleNumber: '101'
Protocol: '6'
RuleAction: allow
Egress: 'true'
CidrBlock: 0.0.0.0/0
PortRange:
From: '80'
To: '80'
OutboundHTTPSNetworkAclEntry:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId:
Ref: NetworkAcl
RuleNumber: '102'
Protocol: '6'
RuleAction: allow
Egress: 'true'
CidrBlock: 0.0.0.0/0
PortRange:
From: '443'
To: '443'
OutboundResponsePortsNetworkAclEntry:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId:
Ref: NetworkAcl
RuleNumber: '103'
Protocol: '6'
RuleAction: allow
Egress: 'true'
CidrBlock: 0.0.0.0/0
PortRange:
From: '1024'
To: '65535'
SubnetNetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId:
Ref: Subnet
NetworkAclId:
Ref: NetworkAcl
InstanceSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
VpcId:
Ref: VPC
GroupDescription: Enable SSH access via port 22
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp:
Ref: SSHLocation
WebServerInstance:
Type: AWS::EC2::Instance
DependsOn: AttachGateway
Properties:
DisableApiTermination: 'FALSE'
IamInstanceProfile:
Ref: InstanceProfile
ImageId:
Fn::FindInMap:
- AWSRegionArch2AMI
- Ref: AWS::Region
- Fn::FindInMap:
- AWSInstanceType2Arch
- Ref: InstanceType
- Arch
InstanceType:
Ref: InstanceType
KeyName:
Ref: KeyName
Monitoring: 'false'
NetworkInterfaces:
- GroupSet:
- Ref: InstanceSecurityGroup
AssociatePublicIpAddress: 'true'
DeviceIndex: '0'
DeleteOnTermination: 'true'
SubnetId:
Ref: Subnet
Tags:
- Key: Name
Value: Amazon DynamoDB Storage Backend for JanusGraph on AWS
UserData:
Fn::Base64:
Fn::Join:
- ''
- - "#!/bin/bash\n"
- "export SDKMAN_DIR=/usr/local/sdkman && curl -s https://get.sdkman.io | bash && source /usr/local/sdkman/bin/sdkman-init.sh\n"
- "echo 'export SDKMAN_DIR=/usr/local/sdkman; source /usr/local/sdkman/bin/sdkman-init.sh' > /etc/profile.d/sdkman.sh\n"
- "yum update && yum upgrade && yum install -y java-1.8.0-openjdk\n"
- "sdk install maven < /dev/null && set -x\n"
- "export GREMLIN_SERVER_USERNAME='ec2-user'\n"
- "export LOG_DIR=/var/log/gremlin-server\n"
- "export SERVER_DIRNAME=dynamodb-janusgraph-storage-backend-1.2.0\n"
- "export SERVER_ZIP=${SERVER_DIRNAME}.zip\n"
- "export PACKAGES_DIR=/usr/local/packages\n"
- "export INSTALL_DIR=${PACKAGES_DIR}/${SERVER_DIRNAME}\n"
- "export REPO_ARCHIVE_DIR=/dev/shm/dynamodb-janusgraph-storage-backend-master\n"
- "mkdir -p ${LOG_DIR} ${INSTALL_DIR}\n"
- "export SERVICE_SCRIPT=${INSTALL_DIR}/bin/gremlin-server-service.sh\n"
- "pushd /dev/shm\n"
- "wget https://github.com/awslabs/dynamodb-janusgraph-storage-backend/archive/master.zip && unzip -q master.zip\n"
- "pushd ${REPO_ARCHIVE_DIR}\n"
- "src/test/resources/install-gremlin-server.sh && popd && popd\n"
- "pushd ${PACKAGES_DIR}\n"
- "mv ${REPO_ARCHIVE_DIR}/server/${SERVER_DIRNAME} . && rm -rf /dev/shm/* && chmod u+x ${SERVICE_SCRIPT} && ln -s ${SERVICE_SCRIPT} /etc/init.d/gremlin-server && chkconfig --add gremlin-server\n"
- "export BACKEND_PROPERTIES=${INSTALL_DIR}/conf/gremlin-server/dynamodb.properties\n"
- "aws s3 cp "
- Ref: "StorageBackendPropertiesFileS3Url"
- " ${BACKEND_PROPERTIES}\n"
- "chown -R ${GREMLIN_SERVER_USERNAME}:${GREMLIN_SERVER_USERNAME} ${LOG_DIR} ${INSTALL_DIR}\n"
- "ln -s ${INSTALL_DIR}/conf /home/ec2-user/conf && chmod a+r /home/ec2-user/conf\n"
- "service gremlin-server start\n\n"
Outputs:
SshTunnels:
Value:
Fn::Join:
- ''
- - ssh -o ServerAliveInterval=50 -nNT -L
- Ref: GremlinServerPort
- ":localhost:"
- Ref: GremlinServerPort
- " -i ${HOME}/.ec2/"
- Ref: KeyName
- ".pem ec2-user@"
- Fn::GetAtt:
- WebServerInstance
- PublicDnsName
Description: Use these SSH tunnels to access Gremlin Server.
GremlinShell:
Value:
Fn::Join:
- ''
- - "ssh -o ServerAliveInterval=50 -t -i ${HOME}/.ec2/"
- Ref: KeyName
- ".pem ec2-user@"
- Fn::GetAtt:
- WebServerInstance
- PublicDnsName
- " /usr/local/packages/dynamodb-janusgraph-storage-backend-1.2.0/bin/gremlin.sh"
Description: Use this remote shell to interact with the graph.
GremlinServerEndpoint:
Value:
Fn::Join:
- ''
- - 'http://localhost:'
- Ref: GremlinServerPort
Description: This is the Gremlin Server Websockets endpoint after creating the
SSH tunnel.
SshAccess:
Value:
Fn::Join:
- ''
- - ssh -o ServerAliveInterval=50 -i ${HOME}/.ec2/
- Ref: KeyName
- ".pem ec2-user@"
- Fn::GetAtt:
- WebServerInstance
- PublicDnsName
Description: This is how you gain remote access to the machine.
Note:
Value: Wait while your EC2 host to boot and start Gremlin Server with the Amazon
DynamoDB Storage Backend for JanusGraph.
Description: ''