Setup database synchronization from AWS RDS to GCP CloudSQL - google-cloud-platform

We want to move our AWS RDS database to GCP CloudSQL. We want to do this without downtime. So our approach was to set up a HA VPN tunnel and use Data Migration Service to sync everything to CloudSQL.
The RDS database is in a private subnet on the AWS side. I've successfully set up a HA VPN tunnel between this AWS private subnet and a private subnet in our GCP project.
I'm able to verify that this works because I can do the following things:
ping from an instance in GCP in the private subnet to an instance in AWS in that private subnet
ping from an instance in AWS in the private subnet to the instance in GCP
After installing MySQL on the GCP instance, I'm able to connect and query the RDS database
I'm struggling with setting up the Data Migration Service in GCP to sync the data from the RDS instance. I've chosen the CloudSQL instance to have a Private IP, not a public one. As connectivity method, I select VPC peering and select the VPC in which the GCP instance from which I'm able to contact the RDS instance resides.
I understand that CloudSQL is created in a project peered to my GCP project, and the CloudSQL instance resides in a subnet in this new project. So there is no route from this subnet to my private subnet. However, I see that it is peered automatically. In this peering connection, I checked the option to import and export custom routes, but still, I cannot reach the RDS from the CloudSQL instance.
I've got routes in GCP for the private subnet IP range of AWS, with the next hop the VPN tunnels.
I'm not sure what I need to do to connect CloudSQL to RDS on this point.

Related

AWS Cloud9 Environment Creation Failing on both Public and Private Subnets

I'm trying to create an AWS Cloud9 environment to access a DocumentDB server for direct access. However, when creating the Cloud9 environment it takes forever then dies with an error regarding an inability to connect to the functional backing EC2 instance. My VPC has 2 public and private subnets and no matter which subnet I use all of them fail with the same error. I have a web server running on the same VPC under one of the private subnets that can be accessed from the open internet perfectly fine and access my DocumentDB database. I have two NAT gateways, one hooked to each of my public subnets. I also have route tables set up to access the open internet. Is there something that could be obviously affecting the Cloud9 environment's ability to connect to it's EC2 instance?
It turns out that my private subnet route tables were misconfigured; they were forwarding 0.0.0.0/0 to an internet gateway, not to my NAT gateway.

how to connect a RDS outside VPC securely?

we want to our RDS outside VPC openly access, but it is not secure to do so.
Is there any solution to help us connect the RDS securely ?
You have two basic options to access an Amazon RDS database. Which you choose depends on your Risk appetite.
Option 1: RDS database in public subnet
For this option, the database is launched in a Public Subnet, with Publicly Available = Yes.
To secure the database, you would configure the Security Group to only permit inbound access from your IP address.
Option 2: RDS database in private subnet
For this option, the database is launched in a Private Subnet, with Publicly Available = No.
You will need some way to 'connect' to the VPC, and then connect to the RDS database. Options for connecting to the VPC could be:
Create an AWS Client VPN, which allows you to connect to the VPC from any location using an OpenVPN-based VPN client, or
Launch an Amazon EC2 instance in the public subnet and connect to it using SSH and Port Forwarding (See: How to use SSH Tunnel to connect to an RDS instance via an EC2 instance?)

Cross Account DMS Replication for RDS instances behind Bastion machines

I have production stacks inside a Production account and development stacks inside a Development account. The stacks are identical and are setup as follows:
Each stack as its own VPC.
Within the VPC are two public subnets spanning to AZs and two private subnets spanning to AZs.
The private Subnets contain the RDS instance.
The public Subnets contain a Bastion EC2 instance which can access the RDS instance.
To access the RDS instance, I either have to SSH into the Bastion machine and access it from there, or I create an SSH tunnel via the Bastion to access it through a Database client application such as PGAdmin.
Current DMS setup:
I would like to be able to use DMS (Database Migration Service) to replication an RDS instance from Production into Development. So far I am trying the following but cannot get it to work:
Create a VPC peering connection between Development VPC and Production VPC
Create a replication instance in the private subnet of the Development VPC
Update the private subnet route tables in the development VPC to route traffic to the CIDR of the production VPC through the VPC peering connection
Ensure the Security group for the replication instance can access both RDS instances.
Main Problem:
When creating the source endpoint in DMS, the wizard only shows RDS instances from the same account and the same region, and only allows RDS instances to be configured using server names and ports, however, the RDS instances in my stacks can only be accessed via Bastion machines using tunnelling. Therefore the test endpoint connection always fails.
Any ideas of how to achieve this cross account replication?
Any good step by step blogs that detail how to do this? I have found a few but they don't seem to have RDS instances sitting behind bastion machines and so they all assume the endpoint configuration wizard can be populated using server names and ports.
Many thanks.
Securing the RDS instances via the Bastion host is sound security practice, of course, for developer/operational access.
For DMS migration service however, you should expect to open security group for both the Target and Source RDS database instances to allow the migration instance to have access to both.
From Network Security for AWS Database Migration Service:
The replication instance must have access to the source and target endpoints. The security group for the replication instance must have network ACLs or rules that allow egress from the instance out on the database port to the database endpoints.
Database endpoints must include network ACLs and security group rules that allow incoming access from the replication instance. You can achieve this using the replication instance's security group, the private IP address, the public IP address, or the NAT gateway’s public address, depending on your configuration.
See
https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Security.Network.html
For network addressing and to open the RDS private subnet, you'll need a NAT on both source and target. They can be added easily, and then terminated after the migration.
You can now use Network Address Translation (NAT) Gateway, a highly available AWS managed service that makes it easy to connect to the Internet from instances within a private subnet in an AWS Virtual Private Cloud (VPC).
See
https://aws.amazon.com/about-aws/whats-new/2015/12/introducing-amazon-vpc-nat-gateway-a-managed-nat-service/

connecting to private aws rds

I'm new and trying to explore AWS and creating a test app running on IIS (EC2 set in Public) and MSSQL RDS(set in Private). However my IIS is not able to connect on the RDS. Looking on my IIS EC2 it has a defined private IP too, same subnet used also from RDS, security group of RDS allows the subnet of the EC2, IAM of EC2 also has RDS Full access.
But still my ec2 wont connect on the RDS. May I ask on what I'm missing on my settings?
It appears that your configuration is:
One VPC
A Public Subnet containing an Amazon EC2 instance
A Private Subnet containing an Amazon RDS for SQL Server instance
You are attempting to connect from the EC2 instance to the RDS db instance
For this to work, you should configure:
A Security Group (let's call it EC2-SG) that is associated with the EC2 instance, permitting connections such that you can login to the EC2 instance
A Security Group (RDS-SG) associated with the RDS db instance, with an incoming connection configured for SQL Server (port 1433) with source set to EC2-SG
That is, the database security group should ALLOW an incoming connection with a source of the security group that is associated to the EC2 instance. The VPC will automatically figure out the IP addresses — you do not need to specify them.
Then, connect from the EC2 instance to the RDS db instance via the DNS Name of the RDS instance that is given in the RDS console.

VPN appliance in AWS VPC

I have a VPC on AWS with a public and a private subnet. I've deployed an instance of OpenVPN appliance in the public subnet to access my EC2 nodes in the private subnet. As expected, with VPN I can access (for e.g. SSH into) any EC2 node that I manually create in the private subnet. But I can't access services (for example Elastic Search or RDS Postgres) that AWS creates in the same private subnet. (I did make sure all security groups are properly configured on the Postgres and RDS). What am I missing?
I use a similar setup when connecting to my private RDS instances via VPN. I apologize, I cannot comment since this account is new and I do not have the reputation, I will have to make assumptions.
Your security groups need to be VPC security groups, not ec2 security groups (if they are not already).
VPC SG 1 (ec2 Bridge): This group is assigned to your OpenVPN server and allows traffic on your Postgres port and private IP CIDR.
Here is an example of mine for MSSQL and MySQL (I have multiple tunnels):
VPC SG 2 (Dev RDS Bridge): This has to allow traffic from VPC SG 1
Here is an example group I made just made for Aurora MySQL:
Finally, assign VPC SG 2 to your RDS Instance:
Now you should be able to talk to your RDS over your VPN connection while the RDS remains closed to the public. The process is similar for other AWS private resources.
Let me know if I wrongly assumed anything or can help more.