Skip to content

Commit

Permalink
(fix) remove all debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin Panemangalore committed Nov 1, 2021
1 parent 028fba8 commit 3529069
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class AuthInputState extends CategoryInputState {

constructor(resourceName: string) {
super(resourceName);
console.log("SACPCDEBUG: ResourceName: ", resourceName );
this.#category = AmplifyCategories.AUTH;
this.#service = AmplifySupportedService.COGNITO;
this.#resourceName = resourceName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ async function configure(context, predictionsResourceObj, configMode /*add/upda
let identifyType;

let parameters = {};
console.log("SACPCDEBUG:1:predictionsResourceObj: ", predictionsResourceObj);

if (predictionsResourceObj) {
const predictionsResourceDirPath = path.join(projectBackendDirPath, category, predictionsResourceObj.name);
const predictionsParametersFilePath = path.join(predictionsResourceDirPath, parametersFileName);
Expand Down Expand Up @@ -149,7 +147,6 @@ async function configure(context, predictionsResourceObj, configMode /*add/upda
identifyType = answers.identifyType;
parameters.resourceName = answers.resourceName;
}
console.log("SACPCDEBUG: Predictions Params ", JSON.stringify(parameters, null, 2));

// category specific questions
Object.assign(answers, await followUpQuestions(identifyAssets[identifyType], identifyType, parameters));
Expand All @@ -166,17 +163,14 @@ async function configure(context, predictionsResourceObj, configMode /*add/upda
if ( answers.adminTask ) {
const s3ResourceName = await invokeS3GetResourceName(context);
const predictionsResourceName = parameters.resourceName;
console.log("SACPCDEBUG: PREDICTIONS : S3ResourceName ", s3ResourceName, "predictionsResourceName: ", parameters.resourceName );

// Check is storage already exists in the project
if (s3ResourceName) {
let s3UserInputs = await invokeS3GetUserInputs(context, s3ResourceName);
s3Resource.bucketName = s3UserInputs.bucketName;
s3Resource.resourceName = s3UserInputs.resourceName;
console.log("SACPCDEBUG:[predictions] S3Bucket exists: ", s3Resource);
// Check if any lambda triggers are already existing in the project.
if (!s3UserInputs.adminTriggerFunction) {
console.log("SACPCDEBUG:[predictions] S3Bucket: AdminTriggerFunction Does *Not* exist ", s3UserInputs );
s3UserInputs = await createAndRegisterAdminLambdaS3Trigger( context, predictionsResourceName, s3Resource.resourceName )
predictionsTriggerFunctionName = s3UserInputs.adminTriggerFunction.triggerFunction
} else {
Expand All @@ -188,17 +182,12 @@ async function configure(context, predictionsResourceObj, configMode /*add/upda
//create admin lamda and register with s3 as trigger
const s3UserInputs = await createAndRegisterAdminLambdaS3Trigger( context, predictionsResourceName, s3Resource.resourceName );
predictionsTriggerFunctionName = s3UserInputs.adminTriggerFunction.triggerFunction
console.log("SACPCDEBUG: DONE invokeS3RegisterAdminTrigger ", s3UserInputs);
}
s3Resource.functionName = predictionsTriggerFunctionName;
console.log("SACPCDEBUG: Identity: Update : ", s3Resource);

/**
* Update function name
*/
console.log("SACPCDEBUG: Updating Function resources : projectBackendDirPath: ",
projectBackendDirPath, " functionCategory: ", functionCategory ,
"predictionsTriggerFunctionName: ", predictionsTriggerFunctionName)
const functionresourceDirPath = path.join(projectBackendDirPath, functionCategory, predictionsTriggerFunctionName);
const functionparametersFilePath = path.join(functionresourceDirPath, parametersFileName);
let functionParameters;
Expand All @@ -210,9 +199,6 @@ async function configure(context, predictionsResourceObj, configMode /*add/upda
functionParameters.resourceName = answers.resourceName || parameters.resourceName;
const functionjsonString = JSON.stringify(functionParameters, null, 4);
fs.writeFileSync(functionparametersFilePath, functionjsonString, 'utf8');


console.log("SACPCDEBUG: Predictions Add Walkthrough Done: functionparametersFilePath: ", functionparametersFilePath);
} else if (parameters.resourceName) {
const s3ResourceName = s3ResourceAlreadyExists(context);
if (s3ResourceName) {
Expand All @@ -221,7 +207,6 @@ async function configure(context, predictionsResourceObj, configMode /*add/upda
s3UserInputs.adminLambdaTrigger.triggerFunction &&
s3UserInputs.adminLambdaTrigger.triggerFunction !== 'NONE'){
const finals3UserInputs = await invokeS3RemoveAdminLambdaTrigger(context, s3ResourceName);
console.log("SACPCDEBUG: Remove S3UserInputs ", finals3UserInputs);
}
}
}
Expand All @@ -230,15 +215,11 @@ async function configure(context, predictionsResourceObj, configMode /*add/upda
delete defaultValues.service;
delete defaultValues.region;
const resourceDirPath = path.join(projectBackendDirPath, category, resourceName);
console.log("SACPCDEBUG: Writing Resource File: ", resourceDirPath);
// write to file
fs.ensureDirSync(resourceDirPath);
const parametersFilePath = path.join(resourceDirPath, parametersFileName);
console.log("SACPCDEBUG: Writing parametersFilePath File: ", parametersFilePath, " defaultValues : ", defaultValues);
const jsonString = JSON.stringify(defaultValues, null, 4);
fs.writeFileSync(parametersFilePath, jsonString, 'utf8');
console.log("SACPCDEBUG: Writing parametersFilePath[DONE] File: ", parametersFilePath, " defaultValues : ", defaultValues);

const options = {};
options.dependsOn = [];
defaultValues.adminTask = answers.adminTask;
Expand Down Expand Up @@ -273,14 +254,11 @@ async function configure(context, predictionsResourceObj, configMode /*add/upda
dependsOn,
identifyType,
};
console.log("SACPCDEBUG: Generating Cloudformation defaultValues : ", defaultValues,
": parameters : ", parameters , "resourceName: ", resourceName );
if (configMode === PREDICTIONS_WALKTHROUGH_MODE.UPDATE) {
// update CFN template
updateCFN(context, resourceName, identifyType);
}
if (configMode === PREDICTIONS_WALKTHROUGH_MODE.ADD) {
console.log("SACPCDEBUG: COPY-CFN : ", category, resourceName, defaultValues);
await copyCfnTemplate(context, category, resourceName, defaultValues);
}
addRegionMapping(context, resourceName, identifyType);
Expand Down Expand Up @@ -447,10 +425,7 @@ async function addS3ForIdentity(context, storageAccess, bucketName, predictionsR
/**
* Create S3 bucket and add admin trigger.
*/
console.log("SACPCDEBUG: Creating S3Bucket from [Predictions]: ", s3UserInputs);
const resultS3UserInput = await invokeS3AddResource(context, s3UserInputs);
console.log("SACPCDEBUG: Done Create S3Bucket from [Predictions]: ", resultS3UserInput);

// getting requirement satisfaction map
const storageRequirements = { authSelections: 'identityPoolAndUserPool', allowUnauthenticatedIdentities };

Expand All @@ -461,8 +436,6 @@ async function addS3ForIdentity(context, storageAccess, bucketName, predictionsR
s3UserInputs.resourceName,
]);

console.log("SACPCDEBUG: CheckResult:1: addS3ForIdentity : ", checkResult);

// If auth is imported and configured, we have to throw the error instead of printing since there is no way to adjust the auth
// configuration.
if (checkResult.authImported === true && checkResult.errors && checkResult.errors.length > 0) {
Expand All @@ -472,7 +445,6 @@ async function addS3ForIdentity(context, storageAccess, bucketName, predictionsR
if (checkResult.errors && checkResult.errors.length > 0) {
context.print.warning(checkResult.errors.join(os.EOL));
}
console.log("SACPCDEBUG: CheckResult:2: : ", checkResult);

// If auth is not imported and there were errors, adjust or enable auth configuration
if (!checkResult.authEnabled || !checkResult.requirementsMet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ export class AmplifyS3ResourceCfnStack extends AmplifyResourceCfnStack implement
{ prefix : 'public/', prefixTransform : S3TriggerPrefixTransform.ATTACH_REGION } ]
}
const newLambdaConfigurations = this.buildLambdaConfigFromTriggerParams( triggerLambdaFunctionParams );
console.log("SACPCDEBUG:1: Trigger Params: ", JSON.stringify(newLambdaConfigurations, null, 2));
this._addNotificationsLambdaConfigurations(newLambdaConfigurations);
this.triggerLambdaPermissions = this.createInvokeFunctionS3Permission('TriggerPermissions', this._props.triggerFunction);
this.s3Bucket.addDependsOn(this.triggerLambdaPermissions as lambdaCdk.CfnPermission);
Expand All @@ -146,7 +145,6 @@ export class AmplifyS3ResourceCfnStack extends AmplifyResourceCfnStack implement
this._props.adminTriggerFunction.triggerFunction != 'NONE' &&
this._props.adminTriggerFunction.triggerFunction != this._props.triggerFunction) {
const adminLambdaConfigurations = this.buildLambdaConfigFromTriggerParams( this._props.adminTriggerFunction );
console.log("SACPCDEBUG:2: Admin Trigger Params: ", JSON.stringify(adminLambdaConfigurations, null, 2));
this._addNotificationsLambdaConfigurations(adminLambdaConfigurations);
this.adminTriggerLambdaPermissions = this.createInvokeFunctionS3Permission('AdminTriggerPermissions', this._props.adminTriggerFunction.triggerFunction );
this.s3Bucket.addDependsOn(this.adminTriggerLambdaPermissions );
Expand All @@ -161,7 +159,6 @@ export class AmplifyS3ResourceCfnStack extends AmplifyResourceCfnStack implement
//Apply all Notifications configurations on S3Bucket;
if (this.notificationConfiguration.lambdaConfigurations &&
(this.notificationConfiguration.lambdaConfigurations as s3Cdk.CfnBucket.LambdaConfigurationProperty[]).length > 0 ) {
console.log("SACPCDEBUG: Add support for all notifications : ", JSON.stringify( this.notificationConfiguration , null, 2 ) );
this.s3Bucket.notificationConfiguration = this.notificationConfiguration;
}

Expand Down Expand Up @@ -456,7 +453,6 @@ export class AmplifyS3ResourceCfnStack extends AmplifyResourceCfnStack implement
}
}
}
console.log(`SACPCDEBUG: buildLambdaConfigFromTriggerParams: ${functionParams.triggerFunction} LambdaConfiguration: `, lambdaConfigurations);
return lambdaConfigurations;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,14 @@ export class AmplifyS3ResourceStackTransform {

async transform(commandType: CLISubCommandType) {
this.generateCfnInputParameters();
console.log("SACPCDEBUG:1:[s3-transform] CfnInputParameters ");

// Generate cloudformation stack from cli-inputs.json
await this.generateStack(this.context);
console.log("SACPCDEBUG:2:[s3-transform] GenerateStack");

// Modify cloudformation files based on overrides
await this.applyOverrides();
console.log("SACPCDEBUG:3:[s3-transform] Apply Overrides");

// Save generated cloudformation.json and parameters.json files
this.saveBuildFiles(commandType);
console.log("SACPCDEBUG:4:[s3-transform] Saved-Build Files ,commandType: ", commandType);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { v4 as uuid } from 'uuid';
import { S3AccessType, S3UserInputs } from '../service-walkthrough-types/s3-user-input-types';

export const getAllDefaults = (project: $TSAny, shortId : string) : S3UserInputs => {
console.log("SACPCDEBUG:[storage] getAllDefaults: projectName: ", project.projectConfig.projectName.toLowerCase(), "shortId: ", shortId );
const name = project.projectConfig.projectName.toLowerCase();
const defaults : S3UserInputs = {
resourceName: `s3${shortId}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ export async function addResource(context: $TSContext, category: string, service
const { addWalkthrough } = await import(serviceWalkthroughSrc);

return addWalkthrough(context, defaultValuesFilename, serviceMetadata, options).then(async (resourceName: string) => {
console.log("SACPCDEBUG: S3 Add Walkthrough: options: ", options);
context.amplify.updateamplifyMetaAfterResourceAdd(category, resourceName, options);

return resourceName;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { createNewLambdaAndUpdateCFN } from './s3-walkthrough';
*/
export function s3GetResourceName(): string | undefined {
const amplifyMeta = stateManager.getMeta();
console.log('SACPCDEBUG: Inside s3GetResourceName', amplifyMeta[AmplifyCategories.STORAGE]);
let resourceName = undefined;
if (amplifyMeta[AmplifyCategories.STORAGE]) {
const categoryResources = amplifyMeta[AmplifyCategories.STORAGE];
Expand All @@ -19,7 +18,6 @@ export function s3GetResourceName(): string | undefined {
}
});
}
console.log('SACPCDEBUG: Returning s3GetResourceName ', resourceName);
return resourceName;
}

Expand All @@ -46,9 +44,7 @@ export async function s3CreateStorageResource(context: $TSContext, storageInput:
if (storageResourceName) {
throw new Error('Add Storage Failed.. already exists');
}
console.log('SACPCDEBUG: addStorageResource : storageInput provided by predictions', storageInput);
await s3APIHelperTransformAndSaveState(context, storageInput, CLISubCommandType.ADD);

return storageInput;
//return storage name
}
Expand Down Expand Up @@ -102,7 +98,6 @@ export async function s3RemoveStorageLambdaTrigger(context: $TSContext, s3Resour
}

s3UserInput.triggerFunction = undefined;
console.log('SACPCDEBUG: S3 trigger Removed: ');
await s3APIHelperTransformAndSaveState(context, s3UserInput, CLISubCommandType.UPDATE);
}

Expand All @@ -128,7 +123,6 @@ export async function s3RemoveStorageLambdaTrigger(context: $TSContext, s3Resour
}
let s3UserInput = cliInputsState.getUserInput();
s3UserInput.adminTriggerFunction = adminLambdaTrigger; //TBD check if function is created
console.log("SACPCDEBUG:[storage]: Registering s3UserInput : ", s3UserInput);
await s3APIHelperTransformAndSaveState(context, s3UserInput, CLISubCommandType.UPDATE);
return s3UserInput;
}
Expand Down Expand Up @@ -187,8 +181,6 @@ async function s3APIHelperTransformAndSaveState(context: $TSContext, storageInpu
} else {
cliInputsState = new S3InputState(storageInput.resourceName as string, undefined );
}
console.log("SACPCDEBUG:s3APIHelperTransformAndSaveState : ", cliInputsState);

cliInputsState.saveCliInputPayload(storageInput);

//Generate Cloudformation
Expand Down

0 comments on commit 3529069

Please sign in to comment.