Wednesday, October 27, 2021

[SOLVED] How should I connect my server to my database

Issue

I have a GO server on an EC2 instance on AWS with the same VPC as my Postgres database. I'm currently able to get the server communicating with the Postgres database by reading the password from an environment variable, but I'm not sure if this is the right way to be handling this. Is there a way I can have the server communicate with the database without having the password stored in plain text?


Solution

There is no need to use your database password to connect the server with the database. Enable IAM authentication in your RDS, and attach that role with the EC2 server running the go server. You can easily find the implementation details here.



Answered By - rohanmehto2