Skip to content

app yaml

ludoch edited this page Apr 15, 2026 · 2 revisions

App Engine app.yaml reference

You configure your App Engine app's settings in the app.yaml configuration file. Your config file must specify at least a runtime entry.

Each service in your app has its own app.yaml file, which acts as a descriptor for its deployment. You must first create the app.yaml file for the default service before you can create and deploy app.yaml files for additional services within your app. To learn more about structuring multiple services in your app, see Structuring Web Services in App Engine.

Syntax

The syntax of app.yaml is the YAML format.

The YAML format supports comments. A line that begins with a pound (#) character is ignored:

# This is a comment.

URL and file path patterns use POSIX extended regular expression syntax, excluding collating elements and collation classes. Back-references to grouped matches (e.g. \1) are supported, as are these Perl extensions: \w \W \s \S \d \D.

Example

The following is an example of an app.yaml file:

runtime: go126

instance_class: F2

env_variables:
  BUCKET_NAME: "example-gcs-bucket"

handlers:
- url: /stylesheets
  static_dir: stylesheets

- url: /(.*\.(gif|png|jpg))$
  static_files: static/\1
  upload: static/.*\.(gif|png|jpg)$

- url: /.*
  script: auto

Each service's folder must contain an app.yaml file and one or more Go source files that include the package main statement at the beginning.

runtime: java25

instance_class: F2

env_variables:
  BUCKET_NAME: "example-gcs-bucket"

handlers:
- url: /stylesheets
  static_dir: stylesheets

- url: /.*
  secure: always
  redirect_http_response_code: 301
  script: auto
runtime: nodejs24

instance_class: F2

env_variables:
  BUCKET_NAME: "example-gcs-bucket"

handlers:
- url: /stylesheets
  static_dir: stylesheets

- url: /.*
  secure: always
  redirect_http_response_code: 301
  script: auto
runtime: php85

handlers:
# Serve a directory as a static resource.
- url: /stylesheets
  static_dir: stylesheets

# Serve images as static resources.
- url: /(.+\.(gif|png|jpg))$
  static_files: \1
  upload: .+\.(gif|png|jpg)$

# Serve your app through a front controller at index.php or public/index.php.
- url: .*
  script: auto

In this example, App Engine serves files with extension of gif, png, or jpg as static resources. The application code reads the configured files at runtime.

runtime: ruby40

instance_class: F2

env_variables:
  BUCKET_NAME: "example-gcs-bucket"

handlers:
- url: /stylesheets
  static_dir: stylesheets

- url: /(.*\.(gif|png|jpg))$
  static_files: static/\1
  upload: static/.*\.(gif|png|jpg)$

- url: /.*
  script: auto
runtime: python314

instance_class: F2

env_variables:
  BUCKET_NAME: "example-gcs-bucket"

handlers:
# Matches requests to /images/... to files in static/images/...
- url: /images
  static_dir: static/images

- url: /.*
  secure: always
  redirect_http_response_code: 301
  script: auto

The following table provides YAML examples of available fields in an app.yaml file:

Runtime and app elements

 <tr id="app_engine_apis">
  <td>
    `app_engine_apis`
  </td>
  <td>

      Optional. If you want to use the
      <a href="/appengine/docs/standard/go/services/access">App Engine legacy bundled services for second-generation runtimes</a>,
      set this field to `true`.

      Optional. If you want to use the
      <a href="/appengine/docs/standard/php-gen2/services/access">App Engine legacy bundled services for second-generation runtimes</a>,
      set this field to `true`.

      Optional. If you want to use the
      <a href="/appengine/docs/standard/python3/services/access">App Engine legacy bundled services for second-generation runtimes</a>,
      set this field to `true`.
  </td>
</tr>

 <tr id="build_environment_variables">
  <td id="handlers_build_environment_variables">
    <a id="app_yaml_Defining_build_environment_variables"></a>
    `build_env_variables`
  </td>
  <td>
    Optional. If you are using a runtime that supports
      <a href="/docs/buildpacks/overview">{{buildpacks_name}}</a>, you
      can define build environment variables in your
      `app.yaml` file.
    To learn more, see <a

href="/appengine/docs/standard/testing-and-deploying-your-app#build-env-vars"> Using build environment variables.

Element Description
default_expiration
      Optional. Sets a global default cache period for all static
      file handlers for an application. You can also configure a <a
      href="#handlers_expiration">cache duration for specific static file
      handlers</a>. The value is a string of numbers and units, separated by
      spaces, where units can be d for days, h for hours, m for minutes, and
      s for seconds. For example, `"4d 5h"` sets cache expiration
      to 4 days and 5 hours after the file is first requested. If omitted,
      the production server sets the expiration to 10 minutes.

Go example:

runtime: go126

default_expiration: "4d 5h"

handlers:
# ...

Node.js example:

runtime: nodejs24

default_expiration: "4d 5h"

handlers:
# ...

PHP example:

runtime: php85

default_expiration: "4d 5h"

handlers:
# ...

Python example:

runtime: python314

default_expiration: "4d 5h"

handlers:
# ...
    For more information, see
    <a href="/appengine/docs/standard/how-requests-are-handled#static_cache_expiration">Cache
    expiration</a>.

  </td>
</tr>
<tr id="entrypoint">
  <td>`entrypoint`</td>
  <td>

    Optional.
    Overrides the default startup behavior by executing the
    `entrypoint` command when your app starts. For your app to
    receive HTTP requests, the `entrypoint` element should
    contain a command which starts a web server that listens on port 8080.

  For more information, see
  <a href="/appengine/docs/standard/go/runtime#application_startup">
  Application startup</a>.

    Optional.
    Overrides the default startup behavior by executing the
    `entrypoint` command when your app starts. For your app to
    receive HTTP requests, the `entrypoint` element should
    contain a command which starts a web server that listens on port 8080.

  For more information, see
  <a href="/appengine/docs/standard/java-gen2/runtime#application_startup">
  Application startup</a>.

    Optional.
    Overrides the default startup behavior by executing the
    `entrypoint` command when your app starts. For your app to
    receive HTTP requests, the `entrypoint` element should
    contain a command which starts a web server that listens on port 8080.

  If you do not specify `entrypoint` for the
    Node.js runtime, App Engine
    <a href="/appengine/docs/standard/nodejs/runtime#application_startup">uses the start script</a>
  specified in your `package.json` file.

    Optional.
    Overrides the default startup behavior by executing the
    `entrypoint` command when your app starts. For your app to
    receive HTTP requests, the `entrypoint` element should
    contain a command which starts a web server that listens on port 8080.

  If you do not specify `entrypoint` for the
    PHP runtime, App Engine
      <a href="/appengine/docs/standard/php-gen2/runtime#application_startup">
      serves your application</a> through a front controller at a
    `public/index.php` or `index.php` file.
  For more information, see
  <a href="/appengine/docs/standard/php-gen2/runtime#application_startup">
  Application startup</a>.

  The command to start your application. The entrypoint starts a process
  that responds to HTTP requests on the port defined by the environment
  variable `PORT`.
  For more information, see
  <a href="/appengine/docs/standard/ruby/runtime#application_startup">
  Application startup</a>.

    Optional.
    Overrides the default startup behavior by executing the
    `entrypoint` command when your app starts. For your app to
    receive HTTP requests, the `entrypoint` element should
    contain a command which starts a web server that listens on port 8080.

  If you do not specify `entrypoint` for the
    Python runtime, App Engine
  <a href="/appengine/docs/standard/python3/runtime#application_startup">
    configures and starts</a> the Gunicorn webserver.
  For more information, see
  <a href="/appengine/docs/standard/python3/runtime#application_startup">
  Application startup</a>.

  </td>
</tr>
<tr id="environment_variables">
  <td id="handlers_environment_variables">
    <a id="app_yaml_Defining_environment_variables"></a>
    `env_variables`
  </td>
  <td>

      Optional.
      You can define environment variables in your `app.yaml`
      file to make them available to your app. Ensure that the key in Environment variable(s) matches the expression '[a-zA-Z_][a-zA-Z0-9_]*' (start with alphabet or "_" followed by any alphanumeric or "_").

      Environment variables that are prefixed with
      `GAE` are reserved for system use and not allowed in the
      `app.yaml` file.

    **Example:**
env_variables:
  MY_VAR: "my value"
      where `MY_VAR` and `my value` are the name and
      value of the environment variable that you want to define and each
      environment variable entry is indented two spaces under the
      `env_variables` element. Environment variables not assigned
      a value default to `"None"`.
    For Go, you can then get these values using
      `os.Getenv`:

    Also see the list of <a href="/appengine/docs/standard/go/runtime#environment_variables">
    runtime environment variables</a> that cannot be overwritten.

    See the list of <a href="/appengine/docs/standard/java-gen2/runtime#environment_variables">
    runtime environment variables</a> that cannot be overwritten.

    **Example:**
env_variables:
  MY_VAR: "my value"
      where `MY_VAR` and `my value` are the name and
      value of the environment variable that you want to define and each
      environment variable entry is indented two spaces under the
      `env_variables` element. Environment variables not assigned
      a value default to `"None"`.
    To retrieve and use your environment variables, you can use
    <a href="https://nodejs.dev/en/learn/how-to-read-environment-variables-from-nodejs/"
      target="_blank" class="external">`process.env`</a>.
    Also see the list of <a href="/appengine/docs/standard/nodejs/runtime#environment_variables">
    runtime environment variables</a> that cannot be overwritten.

    **Example:**
env_variables:
  MY_VAR: "my value"
      where `MY_VAR` and `my value` are the name and
      value of the environment variable that you want to define and each
      environment variable entry is indented two spaces under the
      `env_variables` element. Environment variables not assigned
      a value default to `"None"`.
    For PHP, you can then retrieve the value of these
      variables by using either `getenv()` or
      `$_SERVER`, but **not** `$_ENV`.
      The following commands echo the value of the environment variable
        `MY_VAR`:
echo getenv('MY_VAR');
      or
echo $_SERVER['MY_VAR'];
    Also see the list of <a href="/appengine/docs/standard/php-gen2/runtime#environment_variables">
    runtime environment variables</a> that cannot be overwritten.

    See the list of <a href="/appengine/docs/standard/go/runtime#environment_variables">
    runtime environment variables</a> that cannot be overwritten.

    For Python, these variables are available in the
      `os.environ` dictionary:
env_variables:
          DJANGO_SETTINGS_MODULE: "myapp.settings"
    Also see the list of <a href="/appengine/docs/standard/python3/runtime#environment_variables">
    runtime environment variables</a> that cannot be overwritten.

  </td>
</tr>
<tr id="error_handlers">
  <td>`error_handlers`</td>
  <td>

      Optional.
      Used to configure custom error pages that are returned for different
      error types.

    This element can contain the following elements:
    <dl>
      <dt id="error_code">`error_code`</dt>
      <dd>
        Optional. The `error_code` can be one of the following:
        <dl>
          <dt id="over_quota">`over_quota`</dt>
          <dd>Indicates the app has <a href="/appengine/docs/quotas">
            exceeded a resource quota</a></dd>

          <dt id="timeout">`timeout`</dt>
          <dd>
            Served if a deadline is reached before there is a response from
            your app.
          </dd>
        </dl>

          The error_code is optional; if it's not specified, the given file
          is the default error response for your app.

      </dd>

      <dt id="file">`file`</dt>
      <dd>
        Each file entry indicates a static file that should be served in
        place of the generic error response. If you specify a
        `file` element without a corresponding
        `error_code` element, the static file will be the default
        error page for your app.

Warning: Warning: Make sure that the path to the error response file does not overlap with static file handler paths.

        The custom error data must be less than 10 kilobytes.
      </dd>
    </dl>
    **Example**
  </td>
</tr>
<tr id="handlers">
  <td>`handlers`</td>
  <td>

      Optional.
      A list of URL patterns and descriptions of how they should be handled.
      App Engine can handle URLs by executing application code, or
      by serving static files uploaded with the code, such as images, CSS,
      or JavaScript.

      <a href="#handlers_element">See the Handlers and sub-elements
      syntax</a>.

    For PHP, you must also define a handler for all other
    application traffic to route to an
    <a href="/appengine/docs/standard/php-gen2/runtime#application_startup">`entrypoint`</a>.
    To route to an `entrypoint`, specify the path to your front
    controller with the `entrypoint` element, or use the
    `script` element if your app contains a
    `public/index.php` or `index.php` file.
    For example:
url: .*
script: auto
  </td>
</tr>
<tr id="inbound_services">
  <td>`inbound_services`</td>

  <td>

      Optional.
      Applications must enable those services before it can receive inbound
      requests. You can enable the service for an app
      by including an `inbound_services` section in the
      `app.yaml` file.

<dl>
  <dt id="inbound_service_warmup">`warmup`</dt>
  <dd>
    Enables warmup requests. See <a
    href="/appengine/docs/standard/configuring-warmup-requests">
    Configuring Warmup Requests</a>.
  </dd>
</dl>
**Example:**
inbound_services:
- warmup
  </td>
</tr>
<tr id="instance_class">
  <td>`instance_class`</td>
  <td>

      Optional.
      The <a href="/appengine/docs/standard/#instance_classes">instance class</a> for this service.

      The following values are available depending on your
      service's
      <a href="/appengine/docs/an-overview-of-app-engine#instances">scaling</a>:

    <dl>
      <dt>
        **Automatic scaling**
      </dt>
      <dd>
        `F1`, `F2`, `F4`, `F4_1G`
      </dd>
      <dd>
        *Default:* `F1`

        Optionally use the <a href="#automatic_scaling">
          `automatic_scaling`</a> element to change default
          settings for automatic scaling, such as minimum and maximum
          number of instances, latency, and concurrent connections.

        <p class="note">
        **Note:** If `instance_class`
        is set to `F2` or higher, you can optimize your instances
        by setting <a href="#max_concurrent_requests">
        `max_concurrent_requests`</a> to a value higher than the
        default value of 10. To determine the optimal value,
        gradually increase it and monitor the performance of your
        application.

      </dd>
      <dt>
        **Basic and manual scaling**
      </dt>
      <dd>
        `B1`, `B2`, `B4`, `B4_1G`, `B8`
      </dd>
      <dd>
        *Default:* `B2`

        Basic and manual instance classes require you to specify
          either the <a href="#basic_scaling">
        `basic_scaling`</a> element or the <a href="#manual_scaling">
        `manual_scaling`</a> element.

      </dd>
    </dl>
  </td>
</tr>

<tr id="main">
  <td>`main`</td>
  <td>

      Optional.
      For Go, the path or fully qualified package name of
      the main package. This setting only applies if your app uses
      <a href="/appengine/docs/standard/go/specifying-dependencies#using_go_modules">Go module mode</a>.

      You must declare the path to the main package if your
      `package main` is not in the same directory as your
      `app.yaml`. The `main` element supports file
      paths relative to `app.yaml` or full package names. For
      example, if your app has this directory structure:
myapp/
├── app.yaml
├── go.mod
├── cmd
│   └── web
│       └── main.go
└── pkg
    └── users
        └── users.go
      Then you should use either:
main: ./cmd/web
    or
main: example.com/myapp/cmd/web
  </td>
</tr>

<tr id="runtime">
  <td>`runtime`</td>
  <td>

      Required. The name of the runtime environment that is used by your
      app. For example, to specify the runtime environment, use:
runtime: go126
runtime: java25
runtime: nodejs24
runtime: php85
runtime: ruby40
runtime: python314
  </td>
</tr>
<tr id="service">
  <td>`service`</td>
  <td>

      Required if creating a <a
      href="/appengine/docs/an-overview-of-app-engine">
      service</a>.
      Optional for the `default`
      service. Each service and each version must have a name. A name can
      contain numbers, letters, and hyphens. The combined length of
      `VERSION-dot-SERVICE-dot-PROJECT_ID`, where `VERSION` is the name of
      your version, `SERVICE` is the name of your service, and `PROJECT_ID`
      is your project ID, cannot be longer than 63 characters and cannot
      start or end with a hyphen. Choose a unique name for each service
      and each version. Don't reuse names between services and versions.

    Example:
service: service-name
`service_account`
  Optional. The `service_account` element lets you specify a
  <a href="/appengine/docs/standard/configure-service-accounts#set_a_version-specific_service_account">version-specific service account</a> as the identity for the version. The specified service account is used when accessing other Google Cloud services and executing tasks.

Example:
service_account: [SERVICE_ACCOUNT_NAME]@[PROJECT_ID].
`vpc_access_connector`
  Optional.
  Configures your application to use a Serverless VPC Access
  connector, enabling the application to send requests to internal
  resources in your VPC network. For more information, see
  <a href="/appengine/docs/standard/connecting-vpc">Connecting to a VPC network</a>.

<dl>
  <dt>`name`</dt>
  <dd>String literal. Specify the fully-qualified name of your
    Serverless VPC Access connector in quotes:
"projects/*PROJECT_ID*/locations/*REGION*/connectors/*CONNECTOR_NAME*"
  </dd>
  <dt>`egress_setting`</dt>
  <dd>Optional. Default is `private-ranges-only`. The
    `egress_setting` can be one of the following:
    <dl>
      <dt>`private-ranges-only`</dt>
      <dd>Default. Requests to internal IP addresses are sent through
        the Serverless VPC Access connector into the
        connected VPC network. Requests to external IP
        addresses are sent to the public internet.
      </dd>
      <dt>`all-traffic`</dt>
      <dd>All requests are sent through the
        Serverless VPC Access connector into the
        connected VPC network.
      </dd>
    </dl>
  </dd>
</dl>
**Example**
vpc_access_connector:
  name: "projects/*PROJECT_ID*/locations/*REGION*/connectors/*CONNECTOR_NAME*"
  egress_setting: all-traffic

Handlers element

The handlers element provides a list of URL patterns and descriptions of how they should be handled. App Engine can handle URLs by executing application code, or by serving static files uploaded with the code, such as images, CSS, or JavaScript.

Patterns are evaluated in the order they appear in the app.yaml file, from top to bottom. The first mapping whose pattern matches the URL is the one used to handle the request.

The following table lists the subelements of the handlers element that control the behavior for static files, static directories, scripts in runtimes other than Node.js, and other settings.

<tr id="handlers_auth_fail_action">
  <td>`auth_fail_action`</td>
  <td>
    To use this element,
    `app_engine_apis` must be set to `true`.

      Optional.
      Describes the action taken when the `login` element is
      specified for a handler and the user is not logged in. Has two
      possible values:

    <dl>
      <dt id="handlers_auth_fail_action_redirect">`redirect`</dt>
      <dd>
        Default. The user is redirected to the Google sign-in page, or
        `/_ah/login_required` if OpenID authentication is used.
        The user is redirected back to the application URL after signing in
        or creating an account.
      </dd>
      <dt id="handlers_auth_fail_action_unauthorized">
        `unauthorized`
      </dt>
      <dd>
        The request is rejected with an `HTTP 401` status code
        and an error message.
      </dd>
    </dl>

      If an application needs different behavior, the application itself can
      implement the handling of user logins. For example, requiring a login
      for the `/profile/` directory or an administrator login for
      the `/admin/` directory. See <a
      href="/appengine/docs/standard/authenticating-users">the Users
      API</a> for more information.

      You can configure a handler to refuse access to protected URLs when
      the user is not signed in, instead of redirecting the user to the
      sign-in page, by adding `auth_fail_action: unauthorized` to
      the handler's configuration.

  </td>
</tr>

<tr id="handlers_expiration">
  <td>
    <a id="app_yaml_Static_cache_expiration"></a>
    `expiration`
  </td>
  <td>
    Optional.
    The length of time a static file served by this handler should be
    cached by web proxies and browsers. The value is a string of
    numbers and units, separated by spaces, where units can be
    `d` for days, `h` for hours, `m` for
    minutes, and `s` for seconds. For example,
    `"4d 5h"` sets cache expiration to 4 days and 5 hours after
    the file is first requested. If omitted, the application's
    `default_expiration` is used. See <a
    href="/appengine/docs/standard/how-requests-are-handled#static_cache_expiration">Cache
    expiration</a> for more details.
  </td>
</tr>
<tr id="handlers_http_headers">
  <td>`http_headers`</td>
  <td>

      Optional. You can set <a
      href="https://wikipedia.org/wiki/List_of_HTTP_header_fields">HTTP
      headers</a> for responses of your static file or directory
      handlers.

    If you need to set HTTP headers
      in your `script` handlers, you should instead do that in
      your app's code. For information about which response headers
      influence caching,
      see <a href="/appengine/docs/standard/how-requests-are-handled#caching_static_content">Caching
      static content</a>.

      For more information about App Engine specific headers, see
      <a href="/appengine/docs/standard/reference/request-headers">
      Request headers and responses</a>.

    **Example**
handlers:
- url: /images
  static_dir: static/images
  http_headers:
    X-Foo-Header: foo
    X-Bar-Header: bar value
    vary: Accept-Encoding
  # ...
    <h4>CORS Support</h4>

      One important use of this feature is to support cross-origin resource
      sharing (CORS), such as accessing files hosted by another
      App Engine app.

      For example, you could have a game app `mygame.uc.r.appspot.com`
      that accesses assets hosted by `myassets.uc.r.appspot.com`.
      However, if `mygame` attempts to make a JavaScript
      `XMLHttpRequest` to `myassets`, it will not
      succeed unless the handler for `myassets` returns an
      `Access-Control-Allow-Origin:` response header containing
      the value `http://mygame.uc.r.appspot.com`.

      Here is how you would make your static file handler return that
      required response header value:
handlers:
- url: /images
  static_dir: static/images
  http_headers:
    Access-Control-Allow-Origin: https://mygame.uc.r.appspot.com
  # ...
      Tip: To allow everyone access to your assets, you can
      use the wildcard `'*'`, instead of
      `https://mygame.uc.r.appspot.com`.

  </td>
</tr>

<tr id="handlers_login">
  <td>`login`</td>
  <td>
  To use this element,
  `app_engine_apis` must be set to `true`.

      Optional.
      Determines whether the URL handler requires that the user is signed
      in.
    This element has three possible values:
    <dl>
      <dt id="handlers_login_optional">`optional`</dt>
      <dd>Default. Does not require that the user is signed in.</dd>

      <dt id="handlers_login_required">`required`</dt>
      <dd>
        If the user has signed in, the handler proceeds normally. Otherwise,
        the action given in <a
        href="#handlers_auth_fail_action">`auth_fail_action`</a>
        is taken.
      </dd>

      <dt id="handlers_login_admin">`admin`</dt>
      <dd>
        As with `required`, performs <a
        href="#handlers_auth_fail_action">`auth_fail_action`</a>
        if the user is not signed in. In addition, if the user is not an
        administrator for the application, they are given an error message
        regardless of the <a
        href="#handlers_auth_fail_action">`auth_fail_action`</a>
        setting. If the user is an administrator, the handler proceeds.
      </dd>
    </dl>

      When a URL handler with a `login` setting other than
      `optional` matches a URL, the handler first checks whether
      the user has signed in to the application using its <a
      href="/appengine/docs/standard/users/#Authentication_options">
      authentication option</a>. If not, by default, the user is redirected
      to the sign-in page. You can also use <a
      href="#handlers_auth_fail_action">`auth_fail_action`</a> to
      configure the app to simply reject requests for a handler from users
      who are not properly authenticated, instead of redirecting the user to
      the sign-in page.

      Note: the `admin` login restriction is also satisfied for
      internal requests for which App Engine sets appropriate
      `X-Appengine` special headers.  For example,
      `cron` scheduled tasks satisfy the `admin`
      restriction, because App Engine sets an HTTP header
      `X-Appengine-Cron: true` on the respective requests.
      However, the requests would **not** satisfy the
      `required` login restriction, because cron scheduled tasks
      are not run as any user.

  </td>
</tr>

<tr id="handlers_mime_type">
  <td>`mime_type`</td>
  <td>

      Optional. If specified, all files served by this handler will be
      served using the specified MIME type. If not specified, the MIME type
      for a file will be derived from the file's filename extension.
      If the same file is uploaded with multiple extensions, the resulting
      extension can depend on the order in which the uploads occurred.

      For more information about the possible MIME media types, see <a
      href="http://www.iana.org/assignments/media-types/" target="_blank"
      class="external">the IANA MIME Media Types website</a>.

  </td>
</tr>
<tr id="handlers_redirect_http_response_code">
  <td>`redirect_http_response_code`</td>
  <td>

      Optional. `redirect_http_response_code` is used with the
      `secure` setting to set the HTTP response code returned
      when performing a redirect required by how the `secure`
      setting is configured.
      `redirect_http_response_code` element has the following
      possible values:

    <dl>
      <dt id="handlers_redirect_http_response_code_301">
        `301`
      </dt>
      <dd>Moved Permanently response code.</dd>
      <dt id="handlers_redirect_http_response_code_302">
        `302`
      </dt>
      <dd>
        Found response code.
      </dd>
      <dt id="handlers_redirect_http_response_code_303">
        `303`
      </dt>
      <dd>
        See Other response code.
      </dd>
      <dt id="handlers_redirect_http_response_code_307">
        `307`
      </dt>
      <dd>
        Temporary Redirect response code.
      </dd>
    </dl>

Go example:

handlers:
- url: /youraccount/.*
  script: auto
  secure: always
  redirect_http_response_code: 301

PHP example:

handlers:
- url: /youraccount/.*
  script: auto
  secure: always
  redirect_http_response_code: 301
  When a user's request is redirected, the HTTP status code will be set
  to the value of the `redirect_http_response_code`
  parameter. If the parameter is not present, 302 will be returned.

  </td>
</tr>
<tr id="handlers_script">
  <td>`script`</td>
  <td>

      Optional.
      Specifies that requests to the specific handler should target your
      app. The only accepted value for the `script` element
      is `auto` because all traffic is served using the
      entrypoint command. In order to use static handlers, at least one of
      your handlers must contain the line `script: auto`
      or define an `entrypoint` element to deploy successfully.
handlers:
- url: /images
  static_dir: static/images

- url: /.*
  secure: always
  redirect_http_response_code: 301
  script: auto
handlers:
- url: /images
  static_dir: static/images

- url: /.*
  secure: always
  redirect_http_response_code: 301
  script: auto
handlers:
- url: /images
  static_dir: static/images

- url: /.*
  script: auto
  </td>
</tr>
<tr id="handlers_secure">
  <td>`secure`</td>
  <td>
    Optional. Any URL handler can use the `secure` setting,
    including static file handlers. The `secure` element has the following
    possible values:
    <dl>
      <dt id="handlers_secure_optional">`optional`</dt>
      <dd>
        Both HTTP and HTTPS requests with URLs that match the handler
        succeed without redirects. The application can examine the request
        to determine which protocol was used, and respond accordingly. This
        is the default when `secure` is not provided for a
        handler.
      </dd>
      <dt id="handlers_secure_never">`never`</dt>
      <dd>
        Requests for a URL that match this handler that use HTTPS are
        automatically redirected to the HTTP equivalent URL. When a user's
        HTTPS request is redirected to be an HTTP request,
        the query parameters are removed from the request. This prevents a
        user from accidentally submitting query data over a non-secure
        connection that was intended for a secure connection.
      </dd>
      <dt id="handlers_secure_always">`always`</dt>
      <dd>
        Requests for a URL that match this handler that do not use HTTPS are
        automatically redirected to the HTTPS URL with the same path. Query
        parameters are preserved for the redirect.
      </dd>
    </dl>

Go example

handlers:
- url: /youraccount/.*
  script: auto
  secure: always

Node.js example

handlers:
- url: /youraccount/.*
  secure: always
  script: auto

PHP example

handlers:
- url: /youraccount/.*
  script: auto
  secure: always

Python example

handlers:
- url: /youraccount/.*
  secure: always
  script: auto
      To <a

href="/appengine/docs/standard/how-requests-are-routed"> target a specific version of your app using the REGION_ID.r.appspot.com domain, you replace the periods that would usually separate the subdomain components of the URL with the string "-dot-", for example:
https://VERSION_ID-dot-default-dot-PROJECT_ID.REGION_ID.r.appspot.com

      To use custom domains with HTTPS, you must first <a

href="/appengine/docs/standard/securing-custom-domains-with-ssl"> activate and configure SSL certificates for that domain.

      Google Accounts sign-in and sign-out are always performed using a
      secure connection, unrelated to how the application's URLs are
      configured.

  </td>
</tr>
<tr id="handlers_static_dir">
  <td>
    <a id="app_yaml_Static_directory_handlers"></a>
    `static_dir`
  </td>
  <td>

      Optional. The path to the directory containing the static files, from
      the application root directory. Everything after the end of the
      matched `url` pattern is appended to
      `static_dir` to form the full path to the requested file.

      Each file in the static directory is served using the MIME type that
      corresponds with its filename extension unless overridden by the
      directory's `mime_type` setting. All of the files in the
      given directory are uploaded as static files, and
      none of them can be run as scripts.

    **Example:**
handlers:
# All URLs beginning with /stylesheets are treated as paths to
# static files in the stylesheets/ directory.
- url: /stylesheets
  static_dir: stylesheets
  # ...
  </td>
</tr>
<tr id="handlers_static_files">
  <td>
    `static_files`
  </td>
  <td>

      Optional. A static file pattern handler associates a URL pattern with
      paths to static files uploaded with the application. The URL pattern
      regular expression can define regular expression groupings to be used
      in the construction of the file path. You can use this instead of
      `static_dir` to map to specific files in a directory
      structure without mapping the entire directory.

    **Example:**
handlers:
# All URLs ending in .gif .png or .jpg are treated as paths to
# static files in the static/ directory. The URL pattern is a
# regular expression, with a grouping that is inserted into the
# path to the file.
- url: /(.*\.(gif|png|jpg))$
  static_files: static/\1
  upload: static/.*\.(gif|png|jpg)$
  # ...
      Static files cannot be the same as application code files.

  </td>
</tr>
<tr id="handlers_upload">
  <td>`upload`</td>
  <td>

      Optional. A regular expression that matches the file paths for all
      files that will be referenced by this handler. This is necessary
      because the handler cannot determine which files in your application
      directory correspond with the given `url` and
      `static_files` patterns. Static files are uploaded and
      handled separately from application files. The example
      above might use the following `upload` pattern:
      `archives/(.*)/items/(.*)`

  </td>
</tr>
<tr id="handlers_url">
  <td>`url`</td>
  <td>

      Required element under `handlers`. The URL pattern, as a
      regular expression that can contain groupings. For example,
      `/profile/(.*)/(.*)` would match the URL
      `/profile/edit/manager` and use
      `edit` and `manager` as the first and second
      groupings.

      The URL pattern has some differences in behavior when used with the
      following elements:

    <dl>
      <dt><a href="#handlers_static_dir">`static_dir`</a></dt>
      <dd>
        Uses a URL prefix. The regular express pattern should not contain
        groupings when used with the `static_dir` element. All
        URLs that begin with this prefix are handled by this handler, using
        the portion of the URL after the prefix as part of the file path.
      </dd>
      <dt><a href="#handlers_static_files">
        `static_files`</a>
      </dt>
      <dd>
        A static file pattern handler associates a URL pattern with paths to
        static files uploaded with the application. The URL pattern regular
        expression can define regular expression groupings to be used in the
        construction of the file path. You can use this instead of
        `static_dir` to map to specific files in a directory
        structure without mapping the entire directory.
      </dd>
    </dl>
  </td>
</tr>
Element Description

Scaling elements

The elements in following table configure how your application scales. If no scaling type is specified, then automatic scaling is set by default.

To learn more about how App Engine apps scale, see Scaling types.

Element Description
`automatic_scaling`
      Optional. Applicable only for applications that use an
      <a href="/appengine/docs/standard/reference/app-yaml#instance_class">instance
        class</a> of F1 or higher.
    Specify this element to change default settings for automatic scaling,
      such as setting minimum and maximum levels for number of instances,
      latency, and concurrent connections for a service.

      This element can contain the following elements:

    <dl>
      <dt id="automatic_scaling_max_instances">`max_instances`</dt>
      <dd>
        Optional. Specify a value between 0 and 2147483647, where zero
        disables the setting.

Note: Note: For new projects you create after March 2025, App Engine sets the maximum instances default for standard environment deployments to 20. This change doesn't impact existing apps. To override the default, specify a new value between 0 and 2147483647, and deploy a new version or redeploy over an existing version. To disable the maximum instances default configuration setting, specify the maximum permitted value 2147483647.

        This parameter specifies the maximum number of instances for App
          Engine to create for this module version. This is useful to limit
          the costs of a module.

      </dd>
      <dt id="automatic_scaling_min_instances">`min_instances`</dt>
      <dd>

Warning: Warning: For this feature to function properly, you must make sure that warmup requests are enabled and that your application handles warmup requests.

Note: Note: This setting applies only if the version of the app defined by this app.yaml file is configured to receive traffic. To learn more about routing traffic to different versions of an app, see Splitting Traffic.

        Optional. The minimum number of instances for App Engine to
        create for this module version. These instances serve traffic when
        requests arrive, and continue to serve traffic even when
        additional instances are started up as required to handle traffic.
        Specify a value from 0 to 1000. You can set
        the parameter to the value 0 to allow scaling to 0 instances to
        lower costs when no requests are being served. Note that you are
        charged for the number of instances specified whether they are
          receiving traffic or not.
      </dd>
      <dt id="max_idle_instances">`max_idle_instances`</dt>
      <dd>

          Optional. The maximum number of idle instances that
          App Engine should maintain for this version. Specify a
          value from 1 to 1000. If not specified, the default value is `automatic`,
          which means App Engine will manage
          the number of idle instances.
          Keep the following in mind:
        <ul>
          <li>
            A high maximum reduces the number of idle instances more
            gradually when load levels return to normal after a spike. This
            helps your application maintain steady performance through
            fluctuations in request load, but also raises the number of idle
            instances (and consequent running costs) during such periods of
            heavy load.
          </li>
          <li>
            A low maximum keeps running costs lower, but can degrade
            performance in the face of volatile load levels.
          </li>
        </ul>
        <p class="note">
          **Note:** When settling back to normal levels after a
          load spike, the number of idle instances can temporarily exceed
          your specified maximum. However, you will not be charged for more
          instances than the maximum number you've specified.

      </dd>
      <dt id="min_idle_instances">`min_idle_instances`</dt>
      <dd>

Warning: Warning: For this feature to function properly, you must make sure that warmup requests are enabled and that your application handles warmup requests.

Note: Note: This setting applies only if the version of the app defined by this app.yaml file is configured to receive traffic. To learn more about routing traffic to different versions of an app, see Splitting Traffic.

          Optional: The number of additional instances to be kept running
          and ready to serve traffic for this version.

          App Engine calculates the number of instances necessary to
          serve your current application traffic based on scaling
          settings such as `target_cpu_utilization` and
          `target_throughput_utilization`. Setting `min_idle_instances`
          specifies the number of instances to
          run *in addition to* this calculated number. For example,
          if App Engine calculates that 5 instances
          are necessary to serve traffic, and `min_idle_instances`
          is set to 2, App Engine will run 7 instances (5, calculated
          based on traffic, plus 2 additional per `min_idle_instances`).

          Note that you are
        charged for the number of instances specified whether they are
        receiving traffic or not. Keep the following in mind:

        <ul>
          <li>
            A low minimum helps keep your running costs down during idle
            periods, but means that fewer instances might be immediately
            available to respond to a sudden load spike.
          </li>
          <li id="minimum">

              A high minimum allows you to prime the application for rapid
              spikes in request load. App Engine keeps the minimum
              number of instances running to serve incoming requests. You
              are charged for the number of instances specified, whether or
              not they are handling requests.

              If you set a minimum number of idle instances, pending latency
              will have less effect on your application's performance.

          </li>
        </ul>
      </dd>
      <dt id="automatic_scaling_target_cpu_utilization">`target_cpu_utilization`</dt>
      <dd>
        Optional. Specify a value between 0.5 and 0.95. The default is
        `0.6`.
        This parameter specifies
        the CPU usage threshold at which new instances will be
        started to handle traffic, enabling you to balance between
        performance and cost, with lower values increasing performance and
        increasing cost, and higher values decreasing performance but
        also decreasing cost. For example, a value of 0.7 means that new
          instances will be started after CPU usage reaches 70 percent.
      </dd>
     <dt id="automatic_scaling_target_throughput_utilization">`target_throughput_utilization`</dt>
      <dd>
        Optional. Specify a value from 0.5 to 0.95. The default is
        `0.6`.
        Used with `max_concurrent_requests` to specify when
          a new instance is started due to concurrent requests. When the
          number of concurrent requests reaches a value equal to
          `max_concurrent_requests` times
          `target_throughput_utilization`, the scheduler tries
          to start a new instance.
      </dd>
     <dt id="max_concurrent_requests">
        `max_concurrent_requests`
      </dt>
      <dd>

          Optional. The number of concurrent requests an automatic scaling
          instance can accept before the scheduler spawns a new instance
          (Default: 10, Maximum: 1000).

        Used with `target_throughput_utilization` to
          specify when a new instance is started due to concurrent requests.
          When the number of concurrent requests reaches a value equal to
          `max_concurrent_requests` times
          `target_throughput_utilization`, the scheduler tries to
          start a new instance.

        We recommend you <b>do not set `max_concurrent_requests`
          to less than 10</b> unless you need single threading. A value
          of less than 10 is likely to result in more instances being
          created than you need for a threadsafe app, and that may lead to
          unnecessary cost.

          If this setting is too high, you might experience increased API
          latency. Note that the scheduler might spawn a new instance before
          the actual maximum number of requests is reached.

      </dd>
      <dt id="max_pending_latency">`max_pending_latency`</dt>
      <dd>

          The maximum amount of time that App Engine should allow a request
          to wait in the pending queue before starting additional instances
          to handle requests so that pending latency is reduced. When this
          threshold is reached, it is a signal to scale up, and results in
          an increase in the number of instances.
          If not specified, the default value is `automatic`. This means
          requests can remain in the pending queue for up to 10s, the maximum
          <a href=/appengine/docs/standard/how-requests-are-handled#quotas_and_limits>
          pending request time limit</a>, before new instance starts are triggered.

       A low maximum means App Engine will start new instances
          sooner for pending requests, improving performance but raising
          running costs.

          A high maximum means users might wait longer for their requests
          to be served (if there are pending requests and no idle
          instances to serve them), but your application will cost less to
          run.

      </dd>
      <dt id="min_pending_latency">`min_pending_latency`</dt>
      <dd>

          An optional element you can set to specify the minimum amount of
          time that App Engine should allow a request to wait in the
          pending queue before starting a new instance to handle it.
          Specifying a value can lower running costs but increase the time
          users must wait for their requests to be served.

        For free apps, the default value is `500ms`. For paid
          apps, the default value is `0`.

        This element works together with the `max_pending_latency`
          element to determine when App Engine creates new instances.
          If pending requests are in the queue:

        <ul>
          <li>Less than the `min_pending_latency` you specify,
            App Engine will not create new instances.</li>
          <li>More than `max_pending_latency`, App Engine
            will try to create a new instance.</li>
          <li>Between the time specified by `min_pending_latency`
            and `max_pending_latency`, App Engine will
            try to reuse an existing instance. If no instances are able to
            process the request before `max_pending_latency`,
            App Engine will create a new instance.</li>
        </ul>
      </dd>
    </dl>
    **Example**
  </td>
</tr>
<tr id="basic_scaling">
  <td>`basic_scaling`</td>
  <td>

      Applications that use an
      <a href="/appengine/docs/standard/reference/app-yaml#instance_class">instance
        class</a> of B1 or higher must specify either this element or
      <code><a href="#manual_scaling">manual_scaling</a></code>.

      This element enables basic scaling of instance classes B1 and higher,
      can contain the following elements:

    <dl>
      <dt id="max_instances">`max_instances`</dt>
      <dd>
        Required. The maximum number of instances for App Engine to
        create for this service version. This is useful to limit the costs
        of a service.
      </dd>
      <dt id="idle_timeout">`idle_timeout`</dt>
      <dd>
        Optional. The instance will be shut down this amount of time after
        receiving its last request. The default is 5 minutes
        (`5m`).
      </dd>
    </dl>
    **Example**
  </td>
</tr>
<tr id="manual_scaling">
  <td>`manual_scaling`</td>
  <td>

       Applications that use an
      <a href="/appengine/docs/standard/reference/app-yaml#instance_class">instance
        class</a> of B1 or higher must specify either this element or
      <code><a href="#basic_scaling">basic_scaling</a></code>.

      This element enables manual scaling of instance classes B1 and higher,
      and can contain the following element:

    <dl>
      <dt id="instances">`instances`</dt>
      <dd>
        The number of instances to assign to the service at the start.
      </dd>
    </dl>
    **Example**
  </td>
</tr>

Clone this wiki locally