I have a MongoDB which only allow connection from localhost, running on my ec2. Currently, only my nodejs app which runs on the same ec2 instance connects to the mongodb using this command
Now I'm in the process of migrating my codes to lambda. Since my mongodb only allow localhost connection, currently my lambda won't be able to connect to my mongodb, so I need to open my MongoDB connection to allow connection from external IP right? But I was told by someone (but he's not really sure about it anyway) that I can just use VPC to allow lambda to connect to my MongoDB without needing me to open my MongoDB connection or make any changes to my MongoDB configuration. Is he right on this?
I just started reading about this VPC because I've never used it before, but I'm just asking here for confirmation or any other alternatives.