python - How to use Google Cloud Datastore from existing Compute Engine with different project id? -


google cloud datastore great way share information between app engine , compute engine. this instruction shows how use google cloud datastore compute engine, seems both app engine , compute engine have in same project id.

my datastore inside app engine , compute engine have different project id.

here 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')         , os.getenv('datastore_private_key_file')):       open(os.getenv('datastore_private_key_file'), 'rb') 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 follow instruction 'not compute engine'. hm.. doesn't best way.

is proper way use datastore compute engine under project id?

i recommend consolidate compute engine , app engine under same project, if reason not possible try following:

  1. visit app engine admin console (for app engine app)
  2. select application id google cloud datastore api should enabled.
  3. click application settings link within left hand navigation.
  4. scroll cloud integration section.
  5. if no project showing up, click add project. project creation take few minutes, wait until see google apis console project number in basics section of application settings page.
  6. click on google apis console project number link.
  7. select apis list of services.
  8. scroll google cloud datastore api.
  9. switch google cloud datastore api off on.
  10. visit google cloud console (for compute project)
  11. select existing project id google cloud datastore api should enabled.
  12. select apis list of services.
  13. scroll google cloud datastore api.
  14. switch google cloud datastore api off on.
  15. go permissions
  16. copy compute service account email address (should like: projectid@project.gserviceaccount.com)
  17. visit google cloud console (for app engine app)
  18. go permissions
  19. add compute service account email address

and should work unmodified python client.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -