Is it because of a circular dependency?
# general
a
Is it because of a circular dependency?
b
I believe so. Node.js supports circular dependencies, and will stop the recursion. But that means certain variables may still be undefined during the recursive initialization. I'm not 100% following the file names here (I think file 1 is
savorAdminsUserPool.js
, file 2 is
UserPoolDomain.js
. and file 3 is
UserPoolClient.js
, and that the require in file 2 is actually referring to file 1,
savorAdminsUserPool.js
?) If yes, I suspect the
module.exports
in file 1 hasn't yet been assigned when it is recursively imported from files 2 and 3 during file 1's own initialization. I'm still pondering this ... it seems the UserPool needs to exist before either UserPoolDomain or UserPoolClient -- and yet the UserPool needs the domain and client to create the desired email message! Modules aside, this seems like a circular dependency that cannot be broken.
a
Ah yes you are correct, sorry I should have put in the filenames. I also tried to make the names more generic. Thanks for looking at this! I think my strategy going forward will be to just construct the e-mail message after all resources have been created and export it as an output so it can be copied manually into the Cognito GUI, or when CI/CD comes into play, use the output email message to do an aws cli call to change the e-mail mesage or something.