1

According to the documentation https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions/patch we should be able to stop an app engine instance by changing the serviceStatus to STOPPED.

However, the documentation is ambiguous. Does anyone understand how to stop an app engine instance via the API?

Unclear elements:

  1. "Name of the resource to update. Example: apps/myapp/services/default/versions/1." How can you find the "name of the resource"?
  2. What should the "updateMask" look like? Is it in json?

1 Answer 1

3

Here is the example how you can stop/serve your App Engine version using API, just replace the PROJECTID,SERVICEID and VERSIONID:

curl --request PATCH \ "https://appengine.googleapis.com/v1/apps/PROJECTID/services/SERVICEID/versions/VERSIONID?updateMask=servingStatus" \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ --header "Accept: application/json" \ --header "Content-Type: application/json" \ --data '{"servingStatus":"STOPPED"}' \ --compressed 

For you to fully understand how it builds, there's an API Explorer or a panel. It has a title "Try this API" in the right side of screen, click the box icon to maximize or click this link to redirect. Fill the required fields:

  1. appsId - your PROJECT ID.
  2. servicesId - go to App Engine > Services or execute gcloud command: gcloud app services list to see your App Engine Services. The default name or servicesID of your App Engine Services is default.
  3. versionsId - go to App Engine > Versions or execute gcloud command: gcloud app versions list to see the App Engine versions deployed and copy the VERSION ID you want to update.
  4. updateMask - the configuration in App Engine version you want to update, example: servingStatus or instanceClass

To know more about fields and its definition in API, visit this table of contents. It will help you a lot how you can configure your App Engine Versions via API.

NOTE : You cannot stop the App Engine Version if your apps is configured in automatic scaling.

6
  • Why can't you stop the App Engine Version if the your apps is configured in automatic scaling? Where is this documented? Commented Apr 28, 2021 at 19:14
  • Because auto-scaled service instances are always running. Here's the document. Commented Apr 28, 2021 at 19:17
  • So the only way to stop an auto-scaled instance is to delete it? Commented Apr 28, 2021 at 19:21
  • Yes, absolutely. Commented Apr 28, 2021 at 19:28
  • 1
    @JDOaktown cloud.google.com/sdk/gcloud/reference/app/versions/stop Commented Aug 15, 2022 at 23:34

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.