Skip to content

Commit

Permalink
addressed PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin Panemangalore committed Nov 4, 2021
1 parent 69ecaa8 commit 65d9ecb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { JSONUtilities, stateManager, pathManager } from 'amplify-cli-core';
import {
addTextractPolicies,
generateLambdaAccessForRekognition,
generateStorageAccessForRekognition,
removeTextractPolicies,
removeTextractPolicies
} from '../assets/identifyCFNGenerate';
import identifyAssets from '../assets/identifyQuestions';
import regionMapper from '../assets/regionMapping';
Expand All @@ -14,7 +15,7 @@ import {
invokeS3GetResourceName,
invokeS3GetUserInputs,
invokeS3RegisterAdminTrigger,
invokeS3RemoveAdminLambdaTrigger,
invokeS3RemoveAdminLambdaTrigger
} from './storage-api';
const { ResourceDoesNotExistError, ResourceAlreadyExistsError, exitOnNextTick } = require('amplify-cli-core');
const inquirer = require('inquirer');
Expand Down Expand Up @@ -508,15 +509,14 @@ async function postCFNGenUpdateLambdaResourceInPredictions(context, predictionsR
`${predictionsResourceName}-template.json`,
);
let identifyCFNFile;
identifyCFNFile = context.amplify.readJsonFile(identifyCFNFilePath);
identifyCFNFile = JSONUtilities.readJson(identifyCFNFilePath);

identifyCFNFile = generateLambdaAccessForRekognition(identifyCFNFile, functionName, s3ResourceName);
const identifyCFNString = JSON.stringify(identifyCFNFile, null, 4);
fs.writeFileSync(identifyCFNFilePath, identifyCFNString, 'utf8');
const indentifyCFNFile = JSON.stringify(identifyCFNFile, null, 4);
JSONUtilities.writeJson(identifyCFNFilePath, indentifyCFNFile);

const amplifyMetaFilePath = path.join(projectBackendDirPath, amplifyMetaFilename);
const amplifyMetaFile = context.amplify.readJsonFile(amplifyMetaFilePath);
const dependsOnResources = amplifyMetaFile.predictions[predictionsResourceName].dependsOn;
const amplifyMeta = stateManager.getMeta();
const dependsOnResources = amplifyMeta.predictions[predictionsResourceName].dependsOn;
dependsOnResources.push({
category: functionCategory,
resourceName: functionName,
Expand All @@ -533,7 +533,7 @@ async function postCFNGenUpdateLambdaResourceInPredictions(context, predictionsR
}

async function createNewFunction(context, predictionsResourceName, s3ResourceName) {
const targetDir = context.amplify.pathManager.getBackendDirPath();
const targetDir = pathManager.getBackendDirPath();
const [shortId] = uuid().split('-');
const functionName = `RekognitionIndexFacesTrigger${shortId}`;
const pluginDir = __dirname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ export async function s3RemoveStorageLambdaTrigger(context: $TSContext, s3Resour
s3ResourceName: string,
adminLambdaTrigger: S3UserInputTriggerFunctionParams,
) {
console.log("s3RegisterAdminTrigger : s3ResourceName: ", s3ResourceName , " adminLambdaTrigger: ", adminLambdaTrigger );
let cliInputsState = new S3InputState(s3ResourceName, undefined);
//Check if migration is required
if (!cliInputsState.cliInputFileExists()) {
Expand Down

0 comments on commit 65d9ecb

Please sign in to comment.