Google Cloud Datastore is a great way to share information between app engine and compute engine. This instruction shows how to use google cloud datastore from compute engine, but it seems both app engine and compute engine have to be in a same project id.
My datastore inside app engine and compute engine have different project id.
Here is what i did. in googledatastore/helper.py around line 65, added 1 line
try:
raise client.AccessTokenRefreshError # <== added
credentials = gce.AppAssertionCredentials(connection.SCOPE)
http = httplib2.Http()
credentials.authorize(http)
credentials.refresh(http)
logging.info('connect using compute credentials')
return credentials
except (client.AccessTokenRefreshError, httplib2.HttpLib2Error):
if (os.getenv('DATASTORE_SERVICE_ACCOUNT')
and os.getenv('DATASTORE_PRIVATE_KEY_FILE')):
with open(os.getenv('DATASTORE_PRIVATE_KEY_FILE'), 'rb') as f:
key = f.read()
credentials = client.SignedJwtAssertionCredentials(
os.getenv('DATASTORE_SERVICE_ACCOUNT'), key, connection.SCOPE)
logging.info('connect using DatastoreSignedJwtCredentials')
return credentials
Then ignored compute engine credential. after that just follow instruction for 'not from compute engine'. hm.. It doesn't look best way.
Is it proper way to use datastore from compute engine under another project id?