Cloud SQL Admin Api Warning in GCF - mysql

I have a function deployed in GCF which is executed in node js. And it works with Cloud SQL instance of MySQL.
And I receive this warning from time to time.
CloudSQL warning: your action is needed to update your function and avoid potential disruptions. Please see https://cloud.google.com/functions/docs/sql#troubleshooting for additional details: ensure that the account has access to "-mysql-dev7" (and make sure there's no typo in that name). Error during createEphemeral for -mysql-dev7: googleapi: Error 403: Cloud SQL Admin API has not been used in project 319049 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/sqladmin.googleapis.com/overview?project=319049* then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry., accessNotConfigured
And after this warning function continues to execute. What does it mean? Why function is not halted. If it is not important what does it mean and what if I don't enable this admin API?
BTW function only does selects and updates, it doesn't change table structure so theoretically why would it need Admin API?

I understand the confusion that warning messages may bring, especially if they have no noticeable effects on your function’s workflow.
To the best of my knowledge, the warning identifies that through not enabling this API, there will be potential for further issues when in need of performing certain tasks which require the Cloud SQL Admin API. Potential uses for the Cloud SQL Admin API can be found under public documentation. If you would ever need to list the Cloud SQL instances in a project, get the database of a particular instance, create a new Cloud SQL instance, or perform any other operation listed, please enable the API.
To avoid seeing these warnings all together, I would recommend enabling the API.
EDIT:
Cloud Functions utilizes a mechanism to connect to Cloud SQL instances via the Cloud SQL proxy, the Cloud SQL proxy in turn utilizes the Cloud SQL Admin API.
Therefore when connecting to a Cloud SQL instance without the Cloud SQL Admin API enabled, the error message is thrown.
Cloud Functions is still able to connect to the Cloud SQL instance as it utilizes a legacy connection mechanism when it is unable to do so via the Cloud SQL proxy.
This is why the function does not halt and can still perform the operations on the instance as expected.

Enabling Cloud SQL Admin API will solve the warning:

Related

API Base URL for Google Cloud SQL

I am trying to integrate Google Cloud SQL for Mysql into another application. The other application wants the "api base url". Does anyone know how to get the "api base url" of Google Cloud SQL for Mysql?
If you are using Google Cloud SQL and you are trying to connect your external application this documentation is the best for your case. In that document discuss the summary of connection options, authorization options and code samples also the tools for connecting that will help you to connect in Cloud SQL Mysql instance.
If you are referring to the reference of REST APIs of Cloud SQL and its service-endpoint(https://www.googleapis.com), these are some examples:
Method
Format
Description
delete
DELETE /sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}
Deletes a database from a Cloud SQL instance.
get
GET /sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}
Retrieves a resource containing information about a database inside a Cloud SQL instance.
insert
POST /sql/v1beta4/projects/{project}/instances/{instance}/databases
Inserts a resource containing information about a database inside a Cloud SQL instance.
update
PUT /sql/v1beta4/projects/{project}/instances/{instance}/databases/{database}
Updates a resource containing information about a database inside a Cloud SQL instance.
NOTE: You need to enable the Cloud SQL Admin API before using it.

Can I restrict access to a Google Cloud SQL instance to specific service account?

I have multiple environments in Google Compute Engine (dev, staging, and production), each with its own Google Cloud SQL instance. The instances connect via Cloud SQL Proxy and authenticate with a credential file that is tied to a service account. I want to have a separate service account for each environment, which would be restricted to accessing the SQL instance specific to that environment. Currently, it appears that any service account with role Cloud SQL Client can access any Cloud SQL instance within the same project.
I cannot find any way to restrict access on a Cloud SQL Instance to a specific service account. Is it possible, and if so, how? If not, is there a different way to achieve the goal of preventing a server in one environment from accessing a Cloud SQL instance in another environment?
NOTE: this configuration is possible with Google Cloud Storage; one can assign a specific service account to have various permissions on each bucket, so that the dev service account cannot accidentally access Production files.
Unfortunately, Cloud SQL currently does not support instance level IAM policies.
The only workaround is hosting the instances in different projects.
As of the August 2021 release of Google Cloud SQL:
You can use IAM Conditions to define and enforce conditional, attribute-based access control for Google Cloud resources, including Cloud SQL instances
See the documentation for IAM Conditions for information about how to restrict a user or service account to specific Cloud SQL instances.

Cannot access Google Cloud SQL database from my App Engine

Last week I tried to setup Google Cloud for a NodeJS API and Cloud SQL database. Overall it works fine, but I can't access my Cloud SQL database. The authorization of the SQL database shows that all apps within the current project are granted to access the database. Unfortunality, this is not true. I need to granted the IP addresses of the instances from the App Engine. The IP adressess of the instances constantly changes after I deploy a newer version of the the API.
Does anybody have a solution to get access from the App Engine to the Cloud SQL database. It's very annoying to add constant the instance ip address to grant the database.
Sample here
Thank you in advance!
Jelle
I was going to suggest to assign a static IP to the app engine, but seems like it's not possible in App engine (it's possible in compute engine though). So lets tackle the root of the problem, you being unable to access cloud sql from App engine, are you sure you followed the instructions of the following link to the letter?
https://cloud.google.com/nodejs/getting-started/using-cloud-sql
This might solve your connection issue if you haven't.

Google Cloud SQL monitoring

I am wondering what are the current/existing possibilities of monitoring mysql instances on Google Cloud SQL? What I need is:
define alerts and trigger actions (send via http) for set of mysql metrics
retrive metrics via http
There is not much I see in Google Cloud SQL dashboard for my mysql instance. When I go to Monitoring -> Dashboard & alerts I see that it is disabled due to Stackdriver migration. Am I doing something wrong here or what I want/looking for is not possible at the moment?
Although the dashboard & alerts are not yet available, there is an API to access monitoring statistics: Cloud Monitoring. You would need to build your own alerting/trigger system on top of this at the moment.

App Engine and MySQL

I just wanted to ask if we can access an external MySQL server from Google App Engine...
The only way to communicate with other hosts is by using UrlFetch that only provides HTTP and HTTPS requests.
So, you can't do it out of the box.
Anyway, if you really need to access an external MySQL server database, you should consider to expose it through a Web API (RESTful, Soap web-services for example).
In this way your data would be available also via UrlFetch.
I am still in the learning phase of all this, but I am fairly certain you can do this now a few ways:
Link Apps Scripts to App Engine and use the JDBC
Link it to Google
Cloud SQL Store your SQL database on Google Cloud Store
Connect Apps Scripts via spreadsheet scripting
"Google Apps Script has the ability to make connections to databases via JDBC with the Jdbc Service. The current support extends to MySQL, Microsoft SQL Server and Oracle. Apps Script makes it easy to connect to databases hosted on Google Cloud SQL, but also works with other cloud hosting platforms and even local databases." https://developers.google.com/apps-script/jdbc
(edited for structure)
It is still not possible to native connect GAE to an external MySQL server the only exception is Googles Cloud SQL. We are using it in our production environment and like the experience. Stable and the performance is good.
GAEs own database scales well and we are using it in most situations, but in cases where we need to ask more complex questions or need aggregate functions, we use Googles Cloud SQl.
These answers are a bit outdated. Google App Engine instances can connect to external database servers.
The ability to connect externally requires that the account the App Engine is running under be a "paid account" a/k/a "billing enabled".
References:
-https://cloud.google.com/appengine/docs/php/using-third-party-databases
-https://cloud.google.com/appengine/docs/php/runtime#PHP_Functions_that_requires_billing_enabled