How to patch env_variable using REST API in App Engine Standard?

Viewed 66

Lately I've been deploying apps on App Engine Standard and sometimes I accidentally deploy a version with a typo in my env_variables specified on app.yaml. Let's say that I don't want to deploy a new version because it takes time and this typo should be easily fixed with a "quick patch".

I followed the GAE Admin REST API doc and played around with the API Explorer. It turns out that the request body accepts envVariables so I was thinking that this API can solve my problem but for some reason it fails.

Error:

{
  "error": {
    "code": 400,
    "message": "This operation is only supported on the following field(s): [automatic_scaling.cool_down_period_sec, automatic_scaling.cpu_utilization.target_utilization, automatic_scaling.max_idle_instances, automatic_scaling.max_total_instances, automatic_scaling.min_idle_instances, automatic_scaling.min_total_instances, automatic_scaling.standard_scheduler_settings.max_instances, automatic_scaling.standard_scheduler_settings.min_instances, automatic_scaling.standard_scheduler_settings.target_cpu_utilization, automatic_scaling.standard_scheduler_settings.target_throughput_utilization, instance_class, manual_scaling.instances, serving_status]",
    "status": "INVALID_ARGUMENT"
  }
}


Request Parameters:

  • appsId: PROJECT_ID
  • servicesId: SERVICE_NAME
  • versionsId: 2021xxxxx
  • updateMask: envVariables

Request Body:

{
  "envVariables": {
    "my_key":"my_value"
  }
}

Overall question: Is it not possible to patch env_variables on App Engine Standard using REST API or I'm just missing something? Are there any alternatives to avoid redeployment?

1 Answers

Nope, there is no other alternative for this particular use case.

The reason you cannot modify the envVariables using GAE Rest API is that those variables are used when your app is being built in App Engine, so modifying them will imply re-build all the app which implies at the same time you need to redeploy the app.

You can modify the scaling settings since those not depend on the application or how it is built.

Now, that you're able to see envVariables as an option in the API explorer does not mean it is intended to be used with apps.services.versions.patch, in fact that option is shown as well with others just like a generic menu with all the possible options in the API but in the documentation you share it is not mentioned you can use it for the particular method you mention.

Related