06/16/2019, 3:09 AM
Is it because of a circular dependency?


06/16/2019, 5:04 PM
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
, file 2 is
. and file 3 is
, and that the require in file 2 is actually referring to file 1,
?) If yes, I suspect the
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.


06/16/2019, 7:22 PM
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.