in src/pipelineResources.js [915:1041]
async function createUpdateAWSpipeline ( pipelineName,
neptuneDBName,
neptuneDBregion,
appSyncSchema,
schemaModel,
lambdaFilesPath,
addMutations,
quietI,
__dirname,
isNeptuneIAMAuth,
neptuneHost,
neptunePort,
outputFolderPath,
resolverFilePath,
neptuneType) {
NAME = pipelineName;
REGION = neptuneDBregion;
NEPTUNE_DB_NAME = neptuneDBName;
APPSYNC_SCHEMA = appSyncSchema;
SCHEMA_MODEL = schemaModel;
LAMBDA_FILES_PATH = lambdaFilesPath;
RESOURCES_FILE = `${outputFolderPath}/${NAME}-resources.json`;
ADD_MUTATIONS = addMutations;
quiet = quietI;
NEPTUNE_IAM_AUTH = isNeptuneIAMAuth;
NEPTUNE_HOST = neptuneHost;
NEPTUNE_PORT = neptunePort;
thisOutputFolderPath = outputFolderPath;
NEPTUNE_TYPE = neptuneType;
loggerInfo('Creating or updating AWS pipeline resources ...', {toConsole: true});
await checkPipeline();
if (!pipelineExists) {
loggerInfo('Creating AWS pipeline resources', {toConsole: true});
try {
storeResource({region: REGION});
if (NEPTUNE_TYPE === NEPTUNE_DB) {
try {
startSpinner('Getting Neptune Cluster Info ...', true);
await setNeptuneDbClusterInfo();
succeedSpinner('Retrieved Neptune Cluster Info', {logLevel: 'info'});
if (isNeptuneIAMAuth) {
if (!NEPTUNE_CURRENT_IAM) {
loggerError('The Neptune database authentication is set to VPC.');
loggerError('Remove the --create-update-aws-pipeline-neptune-IAM option.');
exit(1);
}
} else {
if (NEPTUNE_CURRENT_IAM) {
loggerError('The Neptune database authentication is set to IAM.');
loggerError('Add the --create-update-aws-pipeline-neptune-IAM option.');
exit(1);
} else {
loggerDebug(`Subnet Group: ` + yellow(NEPTUNE_DBSubnetGroup), {toConsole: true});
}
}
if (NEPTUNE_CURRENT_VERSION != '') {
const v = NEPTUNE_CURRENT_VERSION;
if (lambdaFilesPath.includes('SDK') == true &&
(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')) {
loggerError("Neptune SDK query is supported starting with Neptune versions 1.2.2.0");
loggerError("Switch to Neptune HTTPS query with option --output-resolver-query-https");
exit(1);
}
}
} catch (error) {
let message = 'Error getting Neptune Cluster Info.';
failSpinner(message);
loggerError(message, error);
if (!isNeptuneIAMAuth) {
loggerError("VPC data is not available to proceed.");
exit(1);
} else {
loggerInfo("Could not read the database ARN to restrict the Lambda permissions. To increase security change the resource in the Neptune Query policy.", {toConsole: true});
loggerInfo("Proceeding without getting Neptune Cluster info.", {toConsole: true});
}
}
}
startSpinner('Creating ZIP ...', true);
ZIP = await createDeploymentPackage(LAMBDA_FILES_PATH, resolverFilePath);
succeedSpinner('Created ZIP File: ' + yellow(LAMBDA_FILES_PATH), {logLevel: 'info'});
await createLambdaRole();
await createLambdaFunction();
await createAppSyncAPI();
loggerInfo('Saved resources to file: ' + yellow(RESOURCES_FILE), {toConsole: true});
} catch (error) {
const message= 'Error creating resources';
failSpinner(message);
loggerError(message, error);
loggerError('Rolling back resources.');
await removeAWSpipelineResources(RESOURCES, quiet);
}
} else {
loggerInfo('Updating AWS pipeline resources', {toConsole: true});
let resources = null;
try {
startSpinner('Loading resources file ...', true);
resources = JSON.parse(fs.readFileSync(RESOURCES_FILE, 'utf8'));
succeedSpinner('Loaded resources from file: ' + yellow(RESOURCES_FILE), {logLevel: 'info'});
} catch (error) {
const message = 'Error loading resources file' + RESOURCES_FILE;
if (!quiet) spinner.warn(message);
loggerError(message, error);
return;
}
startSpinner('Creating ZIP ...', true);
ZIP = await createDeploymentPackage(LAMBDA_FILES_PATH, resolverFilePath);
succeedSpinner('Created ZIP File: ' + yellow(LAMBDA_FILES_PATH), {logLevel: 'info'});
loggerInfo('Updating Lambda function', {toConsole: true});
await updateLambdaFunction(resources);
loggerInfo('Updating AppSync API', {toConsole: true});
await updateAppSyncAPI(resources);
}
}