1

I want to get URL's of services for particular project, how can I do this?
I need URL's like .appspot.com
I tried App Engine Admin api, but it can only provide names of the services.

Lem
  • 99
  • 4
  • 16

3 Answers3

0

The URL of a service other than default follows this pattern:

service-dot-projectID.appspot.com

So for example if your service's name is helloworld and your project ID is myprojectid then the URL would be helloworld-dot-myprojectid.appspot.com

TasosZG
  • 1,184
  • 1
  • 4
  • 12
  • So there is no service discovery api for the Google App Engine services? We need to construct url's by ourselves? – Lem Feb 07 '19 at 13:19
  • No, when you deploy a new service to App Engine the URL is created automatically and follows the above pattern. – TasosZG Feb 07 '19 at 13:23
  • I mean when we wanna deploy to the staging and production, we changing project id to 'project-dev' and 'project', so we need to create manually all url for services with which our service will communicate? – Lem Feb 07 '19 at 13:47
  • You cannot, and you don't have to, create any url for services manually. – TasosZG Feb 07 '19 at 14:01
0

you can get url's of App Engine services's versions through API calls, in 3 steps:

1) authenticate and get an access-token to the App Engine Admin API:

gcloud auth application-default print-access-token

2) with the access token, list all services in App Engine, and get their version ID (in the nested field "allocations"), and service ID:

curl -H "Authorization: Bearer [MY_ACCESS_TOKEN]" https://appengine.googleapis.com/v1/apps/[MY_PROJECT_ID]/services

3) with the version ID and service ID, get the full data on the version:

curl -H "Authorization: Bearer [MY_ACCESS_TOKEN]" https://appengine.googleapis.com/v1/apps/[MY_PROJECT_ID]/services/[SERVICE_ID]/versions/[VERSION_ID]/?view=FULL

The field versionUrl delivers the app URL for this specific version, in the following form:

From there, you can build your own service discovery.

alp
  • 552
  • 3
  • 13
0

If you're manually constructing urls to services within the same project, you may find it easier to setup some dispatch rules.

https://cloud.google.com/appengine/docs/standard/python3/reference/dispatch-yaml

The dispatch.yaml allows you to override routing rules. You can use the dispatch.yaml to send incoming requests to a specific service (formerly known as modules) based on the path or hostname in the URL.

Depending on your needs, you can construct your url off of app_identity.get_default_version_hostname() without worrying about the underlying service, since the dispatch rules will route to the service by the url path.

Kelly
  • 866
  • 9
  • 19