@@ -10,7 +10,7 @@ express or implied. See the License for the specific language governing
10
10
permissions and limitations under the License.
11
11
*/
12
12
13
- import { getNeptuneClusterinfoBy } from './pipelineResources.js'
13
+ import { getNeptuneClusterDbInfoBy } from './pipelineResources.js'
14
14
import { readFile , writeFile } from 'fs/promises' ;
15
15
//import semver from 'semver';
16
16
import fs from 'fs' ;
@@ -23,6 +23,7 @@ let REGION = '';
23
23
let NEPTUNE_DB_NAME = '' ;
24
24
let NEPTUNE_HOST = null ;
25
25
let NEPTUNE_PORT = null ;
26
+ let NEPTUNE_TYPE = null ;
26
27
let NEPTUNE_DBSubnetGroup = null ;
27
28
let NEPTUNE_IAM_POLICY_RESOURCE = '*' ;
28
29
let LAMBDA_ZIP_FILE = '' ;
@@ -73,11 +74,27 @@ async function createDeploymentFile(folderPath, zipFilePath) {
73
74
}
74
75
75
76
76
- async function createAWSpipelineCDK ( pipelineName , neptuneDBName , neptuneDBregion , appSyncSchema , schemaModel , lambdaFilesPath , outputFile , __dirname , quiet , isNeptuneIAMAuth , neptuneHost , neptunePort , outputFolderPath ) {
77
+ async function createAWSpipelineCDK ( {
78
+ pipelineName,
79
+ neptuneDBName,
80
+ neptuneDBregion,
81
+ appSyncSchema,
82
+ schemaModel,
83
+ lambdaFilesPath,
84
+ outputFile,
85
+ __dirname,
86
+ quiet,
87
+ isNeptuneIAMAuth,
88
+ neptuneHost,
89
+ neptunePort,
90
+ outputFolderPath,
91
+ neptuneType
92
+ } ) {
77
93
78
94
NAME = pipelineName ;
79
95
REGION = neptuneDBregion ;
80
96
NEPTUNE_DB_NAME = neptuneDBName ;
97
+ NEPTUNE_TYPE = neptuneType ;
81
98
APPSYNC_SCHEMA = appSyncSchema ;
82
99
SCHEMA_MODEL = schemaModel ;
83
100
NEPTUNE_HOST = neptuneHost ;
@@ -88,50 +105,52 @@ async function createAWSpipelineCDK (pipelineName, neptuneDBName, neptuneDBregio
88
105
let spinner = null ;
89
106
let neptuneClusterInfo = null ;
90
107
91
- try {
92
- if ( ! quiet ) console . log ( 'Get Neptune Cluster Info' ) ;
93
- if ( ! quiet ) spinner = ora ( 'Getting ...' ) . start ( ) ;
94
- neptuneClusterInfo = await getNeptuneClusterinfoBy ( NEPTUNE_DB_NAME , REGION ) ;
95
- if ( ! quiet ) spinner . succeed ( 'Got Neptune Cluster Info' ) ;
96
- if ( isNeptuneIAMAuth ) {
97
- if ( ! neptuneClusterInfo . isIAMauth ) {
98
- console . error ( "The Neptune database authentication is set to VPC." ) ;
99
- console . error ( "Remove the --output-aws-pipeline-cdk-neptune-IAM option." ) ;
100
- process . exit ( 1 ) ;
101
- }
102
- } else {
103
- if ( neptuneClusterInfo . isIAMauth ) {
104
- console . error ( "The Neptune database authentication is set to IAM." ) ;
105
- console . error ( "Add the --output-aws-pipeline-cdk-neptune-IAM option." ) ;
106
- process . exit ( 1 ) ;
108
+ if ( neptuneType === 'neptune-db' ) {
109
+ try {
110
+ if ( ! quiet ) console . log ( 'Get Neptune Cluster Info' ) ;
111
+ if ( ! quiet ) spinner = ora ( 'Getting ...' ) . start ( ) ;
112
+ neptuneClusterInfo = await getNeptuneClusterDbInfoBy ( NEPTUNE_DB_NAME , REGION ) ;
113
+ if ( ! quiet ) spinner . succeed ( 'Got Neptune Cluster Info' ) ;
114
+ if ( isNeptuneIAMAuth ) {
115
+ if ( ! neptuneClusterInfo . isIAMauth ) {
116
+ console . error ( "The Neptune database authentication is set to VPC." ) ;
117
+ console . error ( "Remove the --output-aws-pipeline-cdk-neptune-IAM option." ) ;
118
+ process . exit ( 1 ) ;
119
+ }
107
120
} else {
108
- if ( ! quiet ) console . log ( `Subnet Group: ` + yellow ( neptuneClusterInfo . dbSubnetGroup ) ) ;
121
+ if ( neptuneClusterInfo . isIAMauth ) {
122
+ console . error ( "The Neptune database authentication is set to IAM." ) ;
123
+ console . error ( "Add the --output-aws-pipeline-cdk-neptune-IAM option." ) ;
124
+ process . exit ( 1 ) ;
125
+ } else {
126
+ if ( ! quiet ) console . log ( `Subnet Group: ` + yellow ( neptuneClusterInfo . dbSubnetGroup ) ) ;
127
+ }
109
128
}
110
- }
111
129
112
- if ( neptuneClusterInfo . version != '' ) {
113
- const v = neptuneClusterInfo . version ;
114
- if ( lambdaFilesPath . includes ( 'SDK' ) == true && //semver.satisfies(v, '>=1.2.1.0') ) {
115
- ( v == '1.2.1.0' || v == '1.2.0.2' || v == '1.2.0.1' || v == '1.2.0.0' || v == '1.1.1.0' || v == '1.1.0.0' ) ) {
116
- console . error ( "Neptune SDK query is supported starting with Neptune versions 1.2.1.0.R5" ) ;
117
- console . error ( "Switch to Neptune HTTPS query with option --output-resolver-query-https" ) ;
118
- process . exit ( 1 ) ;
130
+ if ( neptuneClusterInfo . version != '' ) {
131
+ const v = neptuneClusterInfo . version ;
132
+ if ( lambdaFilesPath . includes ( 'SDK' ) == true && //semver.satisfies(v, '>=1.2.1.0') ) {
133
+ ( v == '1.2.1.0' || v == '1.2.0.2' || v == '1.2.0.1' || v == '1.2.0.0' || v == '1.1.1.0' || v == '1.1.0.0' ) ) {
134
+ console . error ( "Neptune SDK query is supported starting with Neptune versions 1.2.1.0.R5" ) ;
135
+ console . error ( "Switch to Neptune HTTPS query with option --output-resolver-query-https" ) ;
136
+ process . exit ( 1 ) ;
137
+ }
119
138
}
120
- }
121
139
122
- NEPTUNE_HOST = neptuneClusterInfo . host ;
123
- NEPTUNE_PORT = neptuneClusterInfo . port ;
124
- NEPTUNE_DBSubnetGroup = neptuneClusterInfo . dbSubnetGroup . replace ( 'default-' , '' ) ;
125
- NEPTUNE_IAM_POLICY_RESOURCE = neptuneClusterInfo . iamPolicyResource ;
126
-
127
- } catch ( error ) {
128
- if ( ! quiet ) spinner . fail ( "Error getting Neptune Cluster Info." ) ;
129
- if ( ! isNeptuneIAMAuth ) {
130
- spinner . clear ( ) ;
131
- console . error ( "VPC data is not available to proceed." ) ;
132
- process . exit ( 1 ) ;
133
- } else {
134
- if ( ! quiet ) console . log ( "Proceeding without getting Neptune Cluster info." ) ;
140
+ NEPTUNE_HOST = neptuneClusterInfo . host ;
141
+ NEPTUNE_PORT = neptuneClusterInfo . port ;
142
+ NEPTUNE_DBSubnetGroup = neptuneClusterInfo . dbSubnetGroup . replace ( 'default-' , '' ) ;
143
+ NEPTUNE_IAM_POLICY_RESOURCE = neptuneClusterInfo . iamPolicyResource ;
144
+
145
+ } catch ( error ) {
146
+ if ( ! quiet ) spinner . fail ( "Error getting Neptune Cluster Info." ) ;
147
+ if ( ! isNeptuneIAMAuth ) {
148
+ spinner . clear ( ) ;
149
+ console . error ( "VPC data is not available to proceed." ) ;
150
+ process . exit ( 1 ) ;
151
+ } else {
152
+ if ( ! quiet ) console . log ( "Proceeding without getting Neptune Cluster info." ) ;
153
+ }
135
154
}
136
155
}
137
156
@@ -147,7 +166,9 @@ async function createAWSpipelineCDK (pipelineName, neptuneDBName, neptuneDBregio
147
166
CDKFile = CDKFile . replace ( "const NAME = '';" , `const NAME = '${ NAME } ';` ) ;
148
167
CDKFile = CDKFile . replace ( "const REGION = '';" , `const REGION = '${ REGION } ';` ) ;
149
168
CDKFile = CDKFile . replace ( "const NEPTUNE_HOST = '';" , `const NEPTUNE_HOST = '${ NEPTUNE_HOST } ';` ) ;
150
- CDKFile = CDKFile . replace ( "const NEPTUNE_PORT = '';" , `const NEPTUNE_PORT = '${ NEPTUNE_PORT } ';` ) ;
169
+ CDKFile = CDKFile . replace ( "const NEPTUNE_PORT = '';" , `const NEPTUNE_PORT = '${ NEPTUNE_PORT } ';` ) ;
170
+ CDKFile = CDKFile . replace ( "const NEPTUNE_DB_NAME = '';" , `const NEPTUNE_DB_NAME = '${ NEPTUNE_DB_NAME } ';` ) ;
171
+ CDKFile = CDKFile . replace ( "const NEPTUNE_TYPE = '';" , `const NEPTUNE_TYPE = '${ NEPTUNE_TYPE } ';` ) ;
151
172
CDKFile = CDKFile . replace ( "const NEPTUNE_DBSubnetGroup = null;" , `const NEPTUNE_DBSubnetGroup = '${ NEPTUNE_DBSubnetGroup } ';` ) ;
152
173
CDKFile = CDKFile . replace ( "const NEPTUNE_IAM_AUTH = false;" , `const NEPTUNE_IAM_AUTH = ${ isNeptuneIAMAuth } ;` ) ;
153
174
CDKFile = CDKFile . replace ( "const NEPTUNE_IAM_POLICY_RESOURCE = '*';" , `const NEPTUNE_IAM_POLICY_RESOURCE = '${ NEPTUNE_IAM_POLICY_RESOURCE } ';` ) ;
0 commit comments