Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to allow cloudbuild steps to access the Cloud SQL in GCP

I'm setting up a cloud build trigger in order to deploy a PHP/Symfony Application. When the docker file runs the php app/console assetic:dump command in order to create the assets I get the following error.

SQLSTATE[HY000] [2002] Connection timed out 
[PDOException] 

SQLSTATE[HY000] [2002] Connection timed out
[Doctrine\DBAL\Driver\PDOException] 


An exception occurred in driver: SQLSTATE[HY000] [2002] 
Connection timed out 
[Doctrine\DBAL\Exception\ConnectionException] 

I have resolved to trying to get the docker container to connect to the database instead of trying to fix the symfony application because I don't know enough about the framework or php.

Is it possible to set this up so that I can allow some kind of IP on the CLOUDSQL side to allow these connections?

like image 932
Pablo Marti Cordero Avatar asked Apr 04 '19 17:04

Pablo Marti Cordero


People also ask

How do I connect Google Cloud to SQL?

In the Google Cloud console, go to the Cloud SQL Instances page. To open the Overview page of an instance, click the instance name. Select Connections from the SQL navigation menu. In the Authorized networks section, click Add network and enter the IP address of the machine where the client is installed.

What are the permissions needed to be given to project members to access cloud build?

By default, only the creator of a Google Cloud project has access to the project and its resources. To grant other users access, you can grant Identity and Access Management (IAM) roles on the project, or on a specific Cloud Build resource.


1 Answers

A solution to setup the proxy in the same step is described in the answer here:

Run node.js database migrations on Google Cloud SQL during Google Cloud Build

like image 167
joost Avatar answered Nov 15 '22 18:11

joost