Unable to connect to Cloud SQL for SQL Server from Cloud Data Fusion - google-cloud-sql

I cannot to access to my private Cloud SQL for SQL Server instance from Data Fusion.
I read documentation and I followed all these steps:
created Cloud SQL for SQL Server instance with private IP on default network
created Data Fusion instance with private IP on default network
created peering connection between Data Fusion on default network
checked peering connection between Cloud SQL on default network
granted to SQL Client role to Data Fusion services account
created a firewall rule to allow traffic from Data Fusion private IP class to default network
installed sql server jdbc drivers on Data Fusion
I'm able to connect to Cloud SQL for SQL Server instance using its private IP from a vm instance bu I cannot connect to same instance from Data Fusion.
Data Fusion returns a timeout error.
Error: Connection timed out: no further information. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.
For MySQL and Postgres there are specific connectors for Cloud SQL but not for SQL Server.
There is someone that has successfully connected a Cloud SQL for SQL Server instance to Data Fusion by private ip?

i try create Data Fusion in private ip and create VPC Peering to my VPC, but still can't acess CloudSQL in private IP, so im create vm haproxy with private IP for that
Data Fusion Private IP ---> Haproxy Private IP ---> CloudSQL Private IP
https://cloud.google.com/data-fusion/docs/how-to/create-private-ip

Related

Datastream can not connect to Cloud SQL with private IP using private connectivity

My Datastream is not able to connect to Cloud SQL (with private IP) using a private connectivity.
I have setup my cloud SQL (Postgres) for replication as it is already streaming events for debezium.
I have created a private connectivity in my VPC and filled the connection profile using my database private IP. Is there anything I am missing ?
Here the error I am receiving:
You must use a TCP proxy in your VPC. Follow that documentation for AlloyDB, it's pretty similar

Connectivity between Cloud Run and Cloud SQL (Internal IP)

I have created my organisation infrastructure in GCP following the Cloud Foundation Toolkit using the Terraform modules provided by Google.
The following table list the IP ranges for all environments:
Now I am in the process of deploying my application that consists of basically Cloud Run services and a Cloud SQL (Postgres) instance.
The Cloud SQL instance was created with a private IP from the "unallocated" IP range that is reserved for peered services (such as Cloud SQL).
In order to establish connectivity between Cloud Run and Cloud SQL, I have also created the Serverless VPC Connector (ip range 10.1.0.16/28) and configured the Cloud SQL proxy.
When I try to connect to the database from the Cloud Run service I get this error after ~10s:
CloudSQL connection failed. Please see https://cloud.google.com/sql/docs/mysql/connect-run for additional details: Post "https://www.googleapis.com/sql/v1beta4/projects/[my-project]/instances/platform-db/createEphemeral?alt=json&prettyPrint=false": context deadline exceeded
I have granted roles/vpcaccess.user for both the default Cloud Run SA and the one used by the application in the host project.
I have granted roles/compute.networkUser for both SAs in the service project. I also granted roles/cloudsql.client for both SAs.
I have enabled servicenetworking.googleapis.com and vpcaccess.googleapis.com in the service project.
I have run out of ideas and I can't figure out what the issue is.
It seems like a timeout error when Cloud Run tries to create a POST request to the Cloud SQL API. So it seems like the VPC connector (10.1.0.16/28) cannot connect to the Cloud SQL instance (10.0.80.0/20).
Has anyone experienced this issue before?
When you use the Cloud SQL built-in connexion in Cloud Run (but also App Engine and Cloud Function) a connexion similar to Cloud SQL proxy is created. This connexion can be achieved only on a Cloud SQL public IP, even if you have a serverless VPC connector and your database reachable through the VPC.
If you have only a private IP on Cloud SQL, you need to use the private IP to reach the database, not the built-in Cloud SQL connector. More detail in the documentation
I also wrote an article on this
If you are using a private IP, you need to check the docker bridge network's IP range. Here is what the documentation says:
If a client cannot connect to the Cloud SQL instance using private IP, check to see if the client is using any IP in the range 172.17.0.0/16. Connections fail from any IP within the 172.17.0.0/16 range to Cloud SQL instances using private IP. Similarly, Cloud SQL instances created with an IP in that range are unreachable. This range is reserved for the docker bridge network.
To resolve some of the issues, you are experiencing, follow the documentation here and post any error messages you receive, for example, you could try:
Try the gcloud sql connect command to connect to your instance. This command authorizes your IP address for a short time. You can run this command in an environment with Cloud SDK and mysql client installed. You can also run this command in Cloud Shell, which is available in the Google Cloud Console and has Cloud SDK and the mysql client pre-installed.
Temporarily allow all IP addresses to connect to an instance. For IPv4 authorize 0.0.0.0/0 (for IPv6, authorize ::/0. After you have tested this, please make sure you remove it again as it opens up to the world!
Are you using connection pools?
If not, I would create a cache of connections so that when your application needs to link to the database, it can get a temporary connection from the pool. Once the application has finished its operation, the connection returns to the pool again for later use. For this to work correctly, the connection needs to be open and closed efficiently and not waste any resources.

Unable to connect to CloudSQL instance that is part of a VPC network

I have created a CloudSQL instance which was part of a VPC I have created.
I'm able to connect to this CloudSQL using CloudSQL Proxy service. But I'm unable to connect to this instance using public IP of the instance though I added the firewall rule to this VPC.
The error I'm getting:
Unable to connect to host <public-ip-of-cloudsql>, or the request timed out.
Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).
MySQL said:
Can't connect to MySQL server on '<public-ip-of-cloudsql>' (4)
Following is the firewall rule I added and provided my home IP address in the blocked out area.
Please let me know if I'm missing something. I can provide more details if needed.
These are the steps you should follow in order to connect to Cloud SQL using the public IP:
Created a Cloud SQL instance, including configuring the default user.
Assuming you use a local client:
2.Install the client.
3.Configure access to your Cloud SQL instance.
4.Connect to your Cloud SQL instance.
You can find a detailed explanation here: Connecting MySQL client using public IP
If you are using the Cloud SQL proxy to connect via public ip, it requires port 3307 to be open to the address.
If you aren't using the Cloud SQL proxy to connect via public ip, you need to authorize your external IP.
I was able to connect CloudSQL which is part of a VPC by just adding the client IP address as Authorized networks.
It's weird, I tried many times before but couldn't succeed. It is working now.
Thanks, guys for answers.

Cannot connect to on-prem SQL Server with Google Cloud Data Fusion

I am trying to test a connection using Cloud Data Fusion to connect to an on-prem SQL Server. Our GCP Project does not use the default network but rather a custom VPC.
It's important to note that security is very important as this database contains healthcare data.
We currently have App Engine Flex code that uses pymssql to query the database on this SQL Server through the VPC, and want to test using Data Fusion.
I have copied and added the generated data fusion service account to IAM with role Cloud Data Fusion API Service Agent.
I have configured in Data Fusion
system.profile.properties.network = <VPC name>
I have verified that the username and password for authentication to SQL Server are valid for the database.
THE VPC network allows port 22 and 1433.
At this point I am just trying to get a successful connection to query a table in the database.
Here is the error message I get:
Connect timed out. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.
Thoughts?
It looks like you can access SQL Server from GCP (via AppEngine Flex Py code) but having trouble connecting through Data Fusion. It also looks like authentication doesnt seem to be a problem (as the error message is around connection).
One area I can think of is to try Cloud Data Fusion private IP, that allows you to securely connect to your VPC from Cloud Data Fusion. This is a new feature and you will need Data Fusion product team support to leverage this feature.

GCP cloud function is unable to connect to GCP SQL instance

GCP Cloud functions use local Socket to connect to SQL instance. But if i disable public ip of SQL instance , this connection does not work. (For security reasons , i want to disable public ip of SQL instance).
And also i tried to connect to SQL instance from Cloud function using private IP of SQL instance . But it failed too.
So my question is, How can i make a connection from Cloud Function to GCP SQL instance when SQL instance's public IP is disabled?
My cloud function is written in "Python 3.7 (Beta)". And Database is postgres
Thanks
The possible answer should be that Cloud functions should have been able to connect to SQL instance using secure & private VPC connection (connected-vpc option) . However it seems this option is possible using alpha version only as of now
https://docs.google.com/forms/d/1-cnuWIpTjbSFAETbpHo4aqgCuhYCGk2qczxHZvNCmFI/viewform?edit_requested=true