Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Connecting Compute Engine instance to AWS RDS instance

Hello,

I'm currently running into an issue attempting to connect an application running on the GCP Compute Engine to an RDS running through AWS. Each time I attempt to connect to the RDS instance I receive the error: (2003, "Can't connect to MySQL server on '<endpoint-name>' (timed out)"). The application works fine when run on a local machine and not a GCP Compute Engine instance.

I was wondering if this was something that could be resolved in order to have the two instances talk to each other properly.

 

Thank you,

Claire

Solved Solved
2 5 830
1 ACCEPTED SOLUTION

Hello @claireaw  ,Welcome on Google Cloud Community.

Did you've added firewall rule, allowing 3306 port for VPC and VM inside this VPC? 
1. Go to your Compute Engine -> Pick VM from which you want to connect with AWS RDS.
2. Search for Network interfaces and click on Network

DamianS_0-1720509543236.png

3. Then go to FIREWALLS -> Add FW rule -> For testing purposes set as on screenshot

DamianS_1-1720509608350.png

4. Wait 1-2 minutes and try to connect to your RDS.

DamianS_2-1720509878662.png

--
cheers,
DamianS
LinkedIn medium.com Cloudskillsboost

View solution in original post

5 REPLIES 5

Hello @claireaw  ,Welcome on Google Cloud Community.

Did you've added firewall rule, allowing 3306 port for VPC and VM inside this VPC? 
1. Go to your Compute Engine -> Pick VM from which you want to connect with AWS RDS.
2. Search for Network interfaces and click on Network

DamianS_0-1720509543236.png

3. Then go to FIREWALLS -> Add FW rule -> For testing purposes set as on screenshot

DamianS_1-1720509608350.png

4. Wait 1-2 minutes and try to connect to your RDS.

DamianS_2-1720509878662.png

--
cheers,
DamianS
LinkedIn medium.com Cloudskillsboost

Hello, 

Thank you for your help. I had discovered that I had a mistake in my security rules, if I recall. The two now connect and function as intended. 

Great !! 🙂 

@DamianS I have done the above steps and tried it out...
the connection is not happening still...

My case is Im running a NodeJS server on GCP Compute instance and Trying to make an MySQL connection through my NodeJS application to the AWS RDS DB..
One thing is that my AWS RDS is in prod mode.
So is it actually possible to make a connection to an AWS RDS which is in prod..
And im sure I have whitelisted the IP address of my GCP compute instance on my AWS RDS Inbound firewall rules to accept the connection from 3306/tcp as well.
So mydoubt is this since the AWS RDS is in PROD.. does it really takes something else more to do to establish a connection?
Please help me out Im a bit new to this cross platform things.
Thankyou

Okay, so lets split our actions to parts:

Did you've ensured that ant single mysql client ( not related with nodeJS app ) is able to connect to DB.?
1. If yes, that's good, because it means that connection from your VM to RDS is able to established and we should debug why your app is not able to connect with DB.
2. If no, we should establish connectivity from your VM first, and then debug the application. 

We must be sure, that from AWS and GCP site FW are configured properly ( means that VM at GCP can reach out RDS on AWS ). You should be able either to use telnet or mysql client to connect to RDS from your VM.

telnet your-rds-endpoint 3306