I'm not able to find the Aurora MySql Db through an EC2 tunnel.
We have an Aurora serverless Db (MySql). The problem is that I don't know how connect to the db locally from my machine.
I tried to add the SSH options to mysqlstring
builder like:
MySqlConnectionStringBuilder _connectionBuilder = new MySqlConnectionStringBuilder()
{
UserID = "admin",
Server = "RDS endpoint in Aws",
Port = 3306,
SshHostName = "Ip to the Ec2",
SshUserName = "the ec2 user",
SshPort = 22,
SshKeyFile = @"filepath to local .pem file",
Database = "db name",
Password = "db-password"
};
I tried to use both string builder and a sshclient like:
using (var sshClient = new SshClient(_connectionBuilder.SshHostName, 22, _connectionBuilder.SshUserName, new PrivateKeyFile(_connectionBuilder.SshKeyFile)))
{
sshClient.Connect();
// SQL QUERY HERE
sshClient.Disconnect();
}
The code works and connects when it is released to the lambda instance but not on my local machine.
Works if I open a CMD window and type:
ssh -N -L 3306:{aws Db endpoint}:3306 -i {path to .pem} {user}@{ip}
And changes server to localhost.