@@ -29,7 +29,7 @@ let spinner = null;
29
29
// find global installation dir
30
30
import path from 'path' ;
31
31
import { fileURLToPath } from 'url' ;
32
- import { parseNeptuneDomainFromEndpoint } from "./util.js" ;
32
+ import { parseNeptuneEndpoint } from "./util.js" ;
33
33
const __filename = fileURLToPath ( import . meta. url ) ;
34
34
const __dirname = path . dirname ( __filename ) ;
35
35
@@ -63,7 +63,7 @@ let createUpdatePipelineNeptuneDatabaseName = '';
63
63
let removePipelineName = '' ;
64
64
let inputCDKpipeline = false ;
65
65
let inputCDKpipelineName = '' ;
66
- let inputCDKpipelineEnpoint = '' ;
66
+ let inputCDKpipelineEndpoint = '' ;
67
67
let inputCDKpipelineFile = '' ;
68
68
let inputCDKpipelineRegion = '' ;
69
69
let inputCDKpipelineDatabaseName = '' ;
@@ -212,10 +212,14 @@ function processArgs() {
212
212
inputCDKpipeline = true ;
213
213
break ;
214
214
case '-ce' :
215
+ // support miss-spelled option for backwards compatibility - could be removed for next major release
216
+ case '--output-aws-pipeline-cdk-neptume-endpoint' :
215
217
case '--output-aws-pipeline-cdk-neptune-endpoint' :
216
- inputCDKpipelineEnpoint = array [ index + 1 ] ;
218
+ inputCDKpipelineEndpoint = array [ index + 1 ] ;
217
219
break ;
218
220
case '-cd' :
221
+ // support miss-spelled option for backwards compatibility - could be removed for next major release
222
+ case '--output-aws-pipeline-cdk-neptume-database-name' :
219
223
case '--output-aws-pipeline-cdk-neptune-database-name' :
220
224
inputCDKpipelineDatabaseName = array [ index + 1 ] ;
221
225
break ;
@@ -285,37 +289,31 @@ async function main() {
285
289
}
286
290
}
287
291
292
+
293
+ let neptuneInfo ;
288
294
// Check if any of the Neptune endpoints are a neptune analytic endpoint and if so, set the neptuneType and IAM to required
289
- const nonEmptyEndpoints = [ inputGraphDBSchemaNeptuneEndpoint , createUpdatePipelineEndpoint , inputCDKpipelineEnpoint ] . filter ( endpoint => endpoint !== '' ) ;
290
- const isNeptuneAnalyticsGraph = nonEmptyEndpoints . length > 0 && parseNeptuneDomainFromEndpoint ( nonEmptyEndpoints [ 0 ] ) . includes ( NEPTUNE_GRAPH ) ;
291
- if ( isNeptuneAnalyticsGraph ) {
292
- neptuneType = NEPTUNE_GRAPH ;
293
- // neptune analytics requires IAM
294
- loggerInfo ( "Detected neptune-graph from input endpoint - setting IAM auth to true as it is required for neptune analytics" )
295
- isNeptuneIAMAuth = true ;
295
+ // only one of these endpoints are expected to be non-empty at the same time
296
+ const nonEmptyEndpoints = [ inputGraphDBSchemaNeptuneEndpoint , createUpdatePipelineEndpoint , inputCDKpipelineEndpoint ] . filter ( endpoint => endpoint !== '' ) ;
297
+ if ( nonEmptyEndpoints . length > 0 ) {
298
+ neptuneInfo = parseNeptuneEndpoint ( nonEmptyEndpoints [ 0 ] ) ;
299
+ neptuneType = neptuneInfo . neptuneType ;
300
+ if ( neptuneType === NEPTUNE_GRAPH ) {
301
+ // neptune analytics requires IAM
302
+ loggerInfo ( "Detected neptune-graph from input endpoint - setting IAM auth to true as it is required for neptune analytics" )
303
+ isNeptuneIAMAuth = true ;
304
+ }
296
305
}
297
306
298
307
// Get Neptune schema from endpoint
299
308
if ( inputGraphDBSchemaNeptuneEndpoint != '' && inputGraphDBSchema == '' && inputGraphDBSchemaFile == '' ) {
300
- let endpointParts = inputGraphDBSchemaNeptuneEndpoint . split ( ':' ) ;
301
- if ( endpointParts . length != 2 ) {
302
- loggerError ( 'Neptune endpoint must be in the form of host:port' ) ;
303
- process . exit ( 1 ) ;
309
+ if ( ! neptuneInfo ) {
310
+ neptuneInfo = parseNeptuneEndpoint ( inputGraphDBSchemaNeptuneEndpoint ) ;
304
311
}
305
- let neptuneHost = endpointParts [ 0 ] ;
306
- let neptunePort = endpointParts [ 1 ] ;
307
-
308
- let neptuneRegionParts = inputGraphDBSchemaNeptuneEndpoint . split ( '.' ) ;
309
- let neptuneRegion = '' ;
310
- if ( neptuneType === NEPTUNE_DB )
311
- neptuneRegion = neptuneRegionParts [ 2 ] ;
312
- else
313
- neptuneRegion = neptuneRegionParts [ 1 ] ;
314
312
315
313
loggerInfo ( 'Retrieving Neptune schema' ) ;
316
- loggerDebug ( 'Getting Neptune schema from endpoint: ' + yellow ( neptuneHost + ':' + neptunePort ) , { toConsole : true } ) ;
314
+ loggerDebug ( 'Getting Neptune schema from endpoint: ' + yellow ( inputGraphDBSchemaNeptuneEndpoint ) , { toConsole : true } ) ;
317
315
318
- setGetNeptuneSchemaParameters ( neptuneHost , neptunePort , neptuneRegion , neptuneType ) ;
316
+ setGetNeptuneSchemaParameters ( neptuneInfo ) ;
319
317
let startTime = performance . now ( ) ;
320
318
inputGraphDBSchema = await getNeptuneSchema ( ) ;
321
319
let endTime = performance . now ( ) ;
@@ -372,15 +370,11 @@ async function main() {
372
370
process . exit ( 1 ) ;
373
371
}
374
372
if ( createUpdatePipelineEndpoint != '' ) {
375
- let parts = createUpdatePipelineEndpoint . split ( '.' ) ;
376
- createUpdatePipelineNeptuneDatabaseName = parts [ 0 ] ;
377
-
378
- let parsedRegion ;
379
- if ( neptuneType === NEPTUNE_DB ) {
380
- parsedRegion = parts [ 2 ] ;
381
- } else {
382
- parsedRegion = parts [ 1 ] ;
373
+ if ( ! neptuneInfo ) {
374
+ neptuneInfo = parseNeptuneEndpoint ( createUpdatePipelineEndpoint ) ;
383
375
}
376
+ createUpdatePipelineNeptuneDatabaseName = neptuneInfo . graphName ;
377
+ const parsedRegion = neptuneInfo . region ;
384
378
385
379
if ( createUpdatePipelineRegion !== parsedRegion ) {
386
380
if ( createUpdatePipelineRegion !== '' ) {
@@ -399,27 +393,37 @@ async function main() {
399
393
// CDK
400
394
if ( inputCDKpipeline ) {
401
395
if ( ! inputGraphDBSchemaNeptuneEndpoint == '' ) {
402
- inputCDKpipelineEnpoint = inputGraphDBSchemaNeptuneEndpoint ;
396
+ inputCDKpipelineEndpoint = inputGraphDBSchemaNeptuneEndpoint ;
403
397
}
404
- if ( inputCDKpipelineEnpoint == '' &&
398
+ if ( inputCDKpipelineEndpoint == '' &&
405
399
inputCDKpipelineRegion == '' && inputCDKpipelineDatabaseName == '' ) {
406
400
loggerError ( 'AWS CDK: is required a Neptune endpoint, or a Neptune database name and region.' ) ;
407
401
process . exit ( 1 ) ;
408
402
}
409
- if ( inputCDKpipelineEnpoint == '' &&
403
+ if ( inputCDKpipelineEndpoint == '' &&
410
404
! inputCDKpipelineRegion == '' && inputCDKpipelineDatabaseName == '' ) {
411
405
loggerError ( 'AWS CDK: a Neptune database name is required.' ) ;
412
406
process . exit ( 1 ) ;
413
407
}
414
- if ( inputCDKpipelineEnpoint == '' &&
408
+ if ( inputCDKpipelineEndpoint == '' &&
415
409
inputCDKpipelineRegion == '' && ! inputCDKpipelineDatabaseName == '' ) {
416
410
loggerError ( 'AWS CDK: a Neptune database region is required.' ) ;
417
411
process . exit ( 1 ) ;
418
412
}
419
- if ( inputCDKpipelineEnpoint != '' ) {
420
- let parts = inputCDKpipelineEnpoint . split ( '.' ) ;
421
- inputCDKpipelineDatabaseName = parts [ 0 ] ;
422
- inputCDKpipelineRegion = parts [ 2 ] ;
413
+ if ( inputCDKpipelineEndpoint != '' ) {
414
+ if ( ! neptuneInfo ) {
415
+ neptuneInfo = parseNeptuneEndpoint ( inputCDKpipelineEndpoint ) ;
416
+ }
417
+ inputCDKpipelineDatabaseName = neptuneInfo . graphName ;
418
+ const parsedRegion = neptuneInfo . region ;
419
+ if ( inputCDKpipelineRegion !== parsedRegion ) {
420
+ if ( inputCDKpipelineRegion !== '' ) {
421
+ loggerInfo ( 'Switching CDK region from ' + inputCDKpipelineRegion + ' to region parsed from endpoint: ' + parsedRegion ) ;
422
+ } else {
423
+ loggerInfo ( 'Region parsed from CDK endpoint: ' + parsedRegion ) ;
424
+ }
425
+ inputCDKpipelineRegion = parsedRegion ;
426
+ }
423
427
}
424
428
if ( inputCDKpipelineName == '' ) {
425
429
inputCDKpipelineName = inputCDKpipelineDatabaseName ;
@@ -576,13 +580,11 @@ async function main() {
576
580
// Create Update AWS Pipeline
577
581
if ( createUpdatePipeline ) {
578
582
try {
579
- let endpointParts = createUpdatePipelineEndpoint . split ( ':' ) ;
580
- if ( endpointParts . length < 2 ) {
581
- loggerError ( 'Neptune endpoint must be in the form of host:port' ) ;
582
- process . exit ( 1 ) ;
583
+ if ( ! neptuneInfo ) {
584
+ neptuneInfo = parseNeptuneEndpoint ( createUpdatePipelineEndpoint ) ;
583
585
}
584
- let neptuneHost = endpointParts [ 0 ] ;
585
- let neptunePort = endpointParts [ 1 ] ;
586
+ let neptuneHost = neptuneInfo . host ;
587
+ let neptunePort = neptuneInfo . port ;
586
588
587
589
await createUpdateAWSpipeline ( createUpdatePipelineName ,
588
590
createUpdatePipelineNeptuneDatabaseName ,
@@ -608,14 +610,11 @@ async function main() {
608
610
try {
609
611
loggerInfo ( 'Creating CDK File' , { toConsole : true } ) ;
610
612
611
- let endpointParts = inputCDKpipelineEnpoint . split ( ':' ) ;
612
- if ( endpointParts . length < 2 ) {
613
- loggerError ( 'Neptune endpoint must be in the form of host:port' ) ;
614
- process . exit ( 1 ) ;
613
+ if ( ! neptuneInfo ) {
614
+ neptuneInfo = parseNeptuneEndpoint ( inputCDKpipelineEndpoint ) ;
615
615
}
616
- let neptuneHost = endpointParts [ 0 ] ;
617
- let neptunePort = endpointParts [ 1 ] ;
618
-
616
+ let neptuneHost = neptuneInfo . host ;
617
+ let neptunePort = neptuneInfo . port ;
619
618
620
619
if ( inputCDKpipelineFile == '' ) {
621
620
inputCDKpipelineFile = `${ outputFolderPath } /${ inputCDKpipelineName } -cdk.js` ;
0 commit comments