0
votes

I'm new to cloud development and am having issues figuring out the best approach for tying App Engine, GCE, and Cloud SQL together.

I have an App Engine application running Django which serves as a user interface for processes happening on GCE instances. The user requests for a task to be started, a GCE instanced is spun up with a RESTful API running on port 80, and the App Engine sends a REST request to the newly spun up GCE instance to start the particular task.

As I have it now, the App Engine instance is storing task information in a Cloud SQL instance. My desire is to have the GCE instances communicate directly with the Cloud SQL instance so that they can update the database and provide a window into the status of tasks for App Engine (by updating database rows).

The problem I'm running into is that as far as I can see the documentation only specifies one way to connect to the SQL instance and that's through giving network access to the IP address of the GCE instance. This is undesirable because I will be spinning up and destroying GCE instances quite frequently and the IP address is subject to change several times.

That being said, I have two questions:

1) Is there a way to avoid the above issue of individually authenticating each GCE instance, and if not what is the best way to approach identifying each GCE instance?

2) Am I going about this the right way? As I said, I'm new to cloud development and am completely guessing here as to how these different services should interact.

1
Without knowing what you're doing on GCE I can't really answer (2) properly, but as a way to manage tasks between App Engine and GCE have you looked at the Task Queue API? You could enqueue tasks from your Python app and consume them from GCE (via the REST API, authenticating with a Service Account) without having to go via Cloud SQL.tx802
The GCE instances are performing tasks which connect to other websites and collect some information. The user requests which website/information to connect to, the GCE instance is spawned and instructed accordingly, and then the GCE tells the App Engine process it's done and gives the results through Cloud SQL. I'll look into the Task Queue API, thanks.Joshua Gilman

1 Answers

1
votes

For the IP that you need to add to the authorized networks in Cloud SQL, if it's a single instance being spin up, you can use an static IP address, although there's a charge for it. You can also use the API Instances:get to get the IP address of your new instance, so when destroying the instance you can remove it from the authorized network. You can use the Cloud SQL API to update the networks.