Eclipse Google Cloud Tools: Where is Datastore running? - eclipse

When running a Java Google App Engine through Eclipse (with Google Cloud Tools) I can inspect my Datastore through the admin dashboard (localhost:8080/_ah/admin/datastore).
Is it possible to access the Datastore Rest API? Where would I be able to do that? Is it running on the same port under a different path?

It looks like Eclipse is starting up dev_appserver.py and with this you can't use Datastore API.
I've never used the Datastore emulator, but that might allow you to use the API.
Another option is to use the live Datastore API for a test GAE project.

If you want to know the port in which the Datastore emulator is listening to calls is by default 8081 and can be changed with gcloud beta emulators datastore start --host-port=localhost:8081
Alternatively, if you want to manually access the Datastore API of your GCP project you can:
Use the Datastore Dashboard in the Cloud Console
Manually make use of the Datastore API as in Try this API feature.
Alternatively

Related

google spanner and direct REST api calls

I'm trying to use spanner emulator and I followed the instructions reported here:
https://cloud.google.com/spanner/docs/emulator
to set it up.
I can use gcloud shell commands to create instance, database, tables, etc. and all works correctly.
But I am not able to use the Rest API directly to access the emulator, even though the google documentation reports it is possible not only to use google client libs to access the emulator, but also the rest api.
The first problem is that it is not clear if I have to use either the base URL
https://spanner.googleapis.com/
or
http://localhost:9020/
When I try with
http://localhost:9020/v1/parent=projects/local-project/instanceConfigs
I always returns and "Not found" message, which means the the Rest API ws are responding, but through gcloud commands I can manage such instance and project!
What am I wrong with?!
According to the official documentation :
Using the Cloud Spanner
Emulator
"The Cloud SDK provides a local, in-memory emulator, which you can
use to develop and test your applications for free without creating a
GCP Project or a billing account."
Therefore you should use the localhost (localhost:9020 for REST requests).
You should use http://localhost:9020 to access the emulator if you want to manually access the REST API, so you were on the right track there.
The URL should however be http://localhost:9020/v1/projects/test-project/instanceConfigs to list all instance configurations on the emulator. Use http://localhost:9020/v1/projects/test-project/instances to list all instances.

Can AWS Toolkit in Eclipse be used with localstack?

For local development, I was hoping to set up a localhost profile for AWS Toolkit that I could then use in Eclipse to interact with resources on localstack, but I'm at a loss to set this up. There is a local(localhost) option in AWS Toolkit, but I don't see how it would know what endpoints to access for the various services in localstack.
It seems like a relatively logical thing to want to do, or do I have to do all my interaction with the aws (or awslocal) cli?

"DatastoreException: Missing or insufficient permissions" on superseded Cloud Datastore

We have an older application based on the AppEngine SDK (now deprecated) and the superseded Cloud Datastore.
In the process of migrating to Google Cloud SDK we also decided to move from JPA/Datanucleus to Objectify.
Given that the Cloud Datastore will be automatically upgraded to Cloud Firestore in Datastore mode sometime in the future, we decided to test our application as described at the bottom of this page:
https://cloud.google.com/datastore/docs/upgrade-to-firestore#testing_an_existing_application
1) Create a new project. In this project, create a Cloud Firestore in Datastore mode database.
2) Using the managed export service, export some of your application's data to Cloud Storage.
3) Using the managed import service, import your application's data to your new project.
4) Copy app logic you want to test to the new project or simulate app behaviour against the new project.
That's what we did and after some issues we could make a portion of our application run fine with the new datastore in a separate test project.
Now to the actual issue...
We wanted to test if the updated application could also run with the superseded Cloud Datastore, so we won't have to worry when the automatic upgrade occurs (as our app will be already ready).
So we deployed it as a new version of the existing AppEngine project (v2-dot-.....): unfortunately running the new version throws a permission error as soon as the app tries to read the datastore:
com.google.cloud.datastore.DatastoreException: Missing or insufficient permissions
So the questions are:
- could this be related to the Cloud Datastore not being upgraded to Cloud Firestore in Datastore mode for our project yet?
- is there anything we can do (add specific permissions maybe) to make it work anyway?
Our concern is that we need to have the new version of the app deployed before July 2020 (that's when the older AppEngine SDK will stop working), and we are worried that the automatic upgrade of the datastore will occur later.
Thank you for your help.
Turned out our project doesn't have the PROJECT_ID#appspot.gserviceaccount.com member in IAM.
It has a pletora of other members (for example: PROJECT_NUMBER-compute#developer.gserviceaccount.com, PROJECT_NUMBER#cloudservices.gserviceaccount.com, service-PROJECT_NUMBER#compute-system.iam.gserviceaccount.com, etc) which I guess are legacy members used in previous versions of Google App Engine.
Adding PROJECT_ID#appspot.gserviceaccount.com with the role Editor fixed the issue: now the new version can be deployed to the old projects and it works fine even if the datastore has not yet been converted to Cloud Firestore in Datastore Mode.
I just ran into this issue and spent way too much time troubleshooting it. Nine times out of ten if you're running into this issue it's because the default App Engine service account doesn't have permission to edit Cloud Datastore. The default App Engine service account is used by default if you're doing a simple gcloud app deploy and nothing else fancy. I solved the problem by giving the default App Engine service account the roles/datastore.owner role with the following:
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="serviceAccount:PROJECT_ID#appspot.gserviceaccount.com" \
--role="roles/datastore.owner"

How to add AppSync backend to AWS MobileHub project via console?

Although awsmobile-cli has a feature for enabling and configuring an AppSync backend like:
awsmobile appsync enable
awsmobile appsync configure
It is prone to end up with a total irrelevant configuration: It creates DynamoDB tables in us-west-2 (Oregon), even if my project is located at eu-central-1 (Frankfurt). And it does so through its default "events" graphql schema. And after all, it does not appear on the MobileHub project console as a backend feature.
Now, the thing I want to do is adding an AppSync backend to AWS MobileHub project via the console. And then I can pull the changes from the cli once I am done i.e. modified the my graphql schema, attached the resolvers and engaged the datasources.
Is it possible as of now?
Unfortunately right now this is not possible via the Mobile Hub console. It is in the CLI roadmap to support importing existing AppSync resources.
As it is not possible to on Mobile Hub right now you could try to use serverless framework together with serverless-appsync-plugin. It allows you to write your infrastructure as code and to deploy it to AWS via CLI.
While Mobile Hub is kinda limiting, you can actually design more complex backend for your app with serverless tool. You can even set up lambda data sources for appsync. Here you can find some examples for different graphql API setups: https://github.com/serverless/serverless-graphql
If you have more or less complex schema it is a right solution to deploy it from CLI as AppSync console starts to lag with big schemas

how to access Google Cloud Datastore through JDO, JPA or Objectify?

I'm using Google Cloud Datastore and I'm ok with it, but I have faced with an issue: is it possible to access Google Cloud Datastore (not GAE) through JDO, JPA or Objectify?
If yes, how to authenticate and connect them?
The Cloud Datastore API does not currently provide client libraries that support JDO, JPA, or Objectify. However, we are working on porting the App Engine Java client library to work on the Cloud Datastore API, and that should enable JDO/JPA/Objectify as well.
https://github.com/GoogleCloudPlatform/google-cloud-datastore/issues/34