Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine what project id my App Engine code is running on

From within an App Engine app, is there a way to determine the project ID a GAE (App Engine) instance is running on?

I want to access a big query table in the same project that the App Engine instance is running in. I'd rather not hard code it in or include it in another config file if possible.

Edit: forgot to mention that this is from Python

like image 466
Kevin S. Avatar asked Aug 28 '14 15:08

Kevin S.


People also ask

How do I find App Engine app ID?

You can access a Google App Engine application at "application-id.appspot.com," where "application-id" is the application's ID. Click an application's ID on the My Applications page to view more information and statistics about the application.

How do I find my project ID?

To locate your project ID: Go to the API Console. From the projects list, select Manage all projects. The names and IDs for all the projects you're a member of are displayed.

What is a project ID?

Project ID: A globally unique identifier for your project. A project ID is a unique string used to differentiate your project from all others in Google Cloud. You can use the Google Cloud console to generate a project ID, or you can choose your own.


1 Answers

I tried the other approaches in 2019 using Python3. So far as I can tell, those approaches are for Python2 (and one for Java).

I was able to accomplish this in Python3 using:

import os

app_id = os.getenv('GAE_APPLICATION')
print(app_id)
project_id = os.getenv('GOOGLE_CLOUD_PROJECT')
print(project_id)

source: https://cloud.google.com/appengine/docs/standard/python3/runtime

like image 137
jeremydeanlakey Avatar answered Sep 27 '22 22:09

jeremydeanlakey