App Engine app.yaml reference Stay organized with collections Save and categorize content based on your preferences.
Region ID
TheREGION_ID is an abbreviated code that Google assignsbased on the region you select when you create your app. The code does notcorrespond to a country or province, even though some region IDs may appearsimilar to commonly used country and province codes. For apps created after February 2020,REGION_ID.r is included in App Engine URLs. For existing apps created before this date, the region ID is optional in the URL.
Learn moreabout region IDs.
You configure your App Engine app's settings in theapp.yamlfile.This file specifies how URL paths correspond to request handlers andstatic files.Theapp.yaml file also contains information about yourapp's code, such as the runtime and the latest versionidentifier.
Eachservicein your app has its ownapp.yaml file, which acts as a descriptor for itsdeployment. You must first create theapp.yaml file for thedefault servicebefore you can create and deployapp.yaml files for additional services withinyour app.
Directory structure
To learn more about structuring multiple services in your app, seeStructuring Web Services in App Engine.Example
The following is an example of anapp.yaml file for a Python 2application:
runtime:python27api_version:1threadsafe:truehandlers:-url:/script:home.app-url:/index\.htmlscript:home.app-url:/stylesheetsstatic_dir:stylesheets-url:/(.*\.(gif|png|jpg))$static_files:static/\1upload:static/.*\.(gif|png|jpg)$-url:/admin/.*script:admin.applogin:admin-url:/.*script:not_found.app
Ascript: directive can contain either afile path ending in.py, whichmeans the script uses CGI, or aPython module path, with package namesseparated by dots, which means the script uses WSGI.
Syntax
The syntax ofapp.yaml is theYAML 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 usePOSIX extended regular expressionsyntax, excluding collatingelements and collation classes. Back-references to grouped matches (e.g.\1)are supported, as are these Perl extensions:\w \W \s \S \d \D.
Runtime and app elements
| Element | Description |
|---|---|
application | Warning: Theapplication element in addition to using theappcfg tooling have beenshut down. See the following instructions to specify your application using theGoogle Cloud CLI tooling such as thegcloud command line. The recommended approach is to remove the
For more information about using these commands, see Deploying Your App. The application ID is the Google Cloud console project ID that you specified when you created the application in theGoogle Cloud console. |
api_version | Required. The version of the API in the given runtime environment that is used by your app. This field isdeprecated in newer App Engine runtimes. When Google announces support for a new version of a runtime environment's API, your deployed app will continue to use the one for which it was written. To upgrade your app to a new version of the API, you change this value and then redeploy your app to App Engine. When you specify the At this time, App Engine has one version of the |
auto_id_policy | Optional. If you are setting entity identifiers automatically, you can change the method employed by setting the auto ID policy. The following are valid options:
|
builtins | Optional. The Python 2 SDK includes a number of built-in handlers for common application functions. The This field isdeprecated in the Python 3 runtime. The following built-in handlers are available for your use:
builtins:-deferred:on-appstats:on The builtins:-name:on Is equivalent to: includes:-$PYTHON_LIB/google/appengine/ext/builtins/name/ When you use For example, consider the following handlers:-url:/.*script:main.appbuiltins:-appstats:on The resulting list of handlers is: [/_ah/stats,/.*] If the includes:-included.yaml And the handlers:-url:/.*script:main.appbuiltins:-appstats:on The resultant list of handlers is now: [/.*,/_ah/stats] The order of placement of the |
default_expiration | Optional. Sets a global default cache period for all static file handlers for an application. You can also configure acache duration for specific static file handlers. 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, runtime:python27api_version:1threadsafe:truedefault_expiration:"4d5h"handlers:# ... For more information, seeCache expiration. |
env_variables | Optional. You can define environment variables in your Environment variables that are prefixed with os.environ dictionary:env_variables:DJANGO_SETTINGS_MODULE:"myapp.settings" |
error_handlers | Optional. Used to configure custom error pages that are returned for different error types. This element can contain the following elements:
error_handlers:-file:default_error.html-error_code:over_quotafile:over_quota.html |
handlers | Required. 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. |
includes | Optional. The includes:-lib/user_admin.yaml App Engine resolves the included path in the following order:
If the Included |
inbound_services | Optional. Applications must enable those services before it can receive inbound requests. You can enable the service for a Python 2 app by including an The following inbound services are available:
inbound_services:-mail-warmup |
instance_class | Optional. Theinstance class for this service. The following values are available depending on your service'sscaling:
|
libraries | Optional. The Python 2.7 runtime includes somethird-party libraries. Some of these are available by default; others are only available if configured. You can specify which version you want to use by specifying the This field isdeprecated in the Python 3 runtime. libraries:-name:PILversion:"1.1.7"-name:webobversion:"latest" Note than when you specify If you're developing an application that doesn't have users yet: you don't need to track new versions. But if your application is being actively used, beware: you might be surprised that your application starts using a new not-backward-compatible library version. For a list of the included third-party libraries, seeThird-party Libraries. You can use additional pure-python third-party libraries byinstalling them into a local directory. If you are using the flexible environment, seeUsing Python libraries in the flexible environment. |
module | Note:Modules are now named Services. To manage your app with the gcloud CLI, use theservice element instead. |
runtime | Required. The name of the runtime environment that is used by your app. For example, to specify Python 2.7, use: runtime:python27 |
service | Services were formerly known as Modules. Supported only by the gcloud CLI or gcloud CLI-based plugins, for example: Required if creating a service. Optional for the service:service-name Note: The module:service-name |
service_account | Optional. The service_account:[SERVICE_ACCOUNT_NAME]@[PROJECT_ID].iam.gserviceaccount.com |
skip_files | Optional. The The skip_files:-^(.*/)?#.*#$-^(.*/)?.*~$-^(.*/)?.*\.py[co]$-^(.*/)?.*/RCS/.*$-^(.*/)?\..*$ The default pattern excludes Emacs backup files with names of the form To extend the above regular expression list, copy and paste the above list into your skip_files:-^(.*/)?#.*#$-^(.*/)?.*~$-^(.*/)?.*\.py[co]$-^(.*/)?.*/RCS/.*$-^(.*/)?\..*$-^(.*/)?.*\.bak$ To skip a full directory, add the directory name to the list. For example, to skip a directory named skip_files:-logs/ |
threadsafe | Required. Configures your application to use concurrent requests. If using Python's threading library, the thread-local data, as returned by This field isdeprecated in the Python 3 runtime. threadsafe:[true | false] Note: The |
version | The recommended approach is to remove the
For more information about using this command, see Deploying Your App. An identifier for the version of your application code that you deploy to App Engine. The version ID can contain lowercase letters, digits, and hyphens. It cannot begin with the prefix Note: Version names should begin with a letter, to distinguish them from numeric instances which are always specified by a number. This avoids the ambiguity with URLs like Each version of an application retains its own copy of |
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, seeConnecting to a VPC network.
vpc_access_connector:name:"projects/PROJECT_ID/locations/REGION/connectors/CONNECTOR_NAME"egress_setting:all-traffic |
Handlers element
Thehandlers element is a required element in theapp.yaml configuration file. The element provides a list of URLpatterns and descriptions of how they should be handled. App Engine canhandle URLs by executing application code, or by serving static files uploadedwith the code, such as images, CSS, or JavaScript.
Patterns are evaluated in the order they appear in theapp.yaml file, fromtop to bottom. The first mapping whose pattern matches the URL is the one usedto handle the request.
The following table lists the subelements of thehandlers element that controlthe behavior for scripts, static files,static directories, and other settings.
| Element | Description |
|---|---|
application_readable | Optional. Boolean. By default, files declared in static file handlers are uploaded as static data and are only served to end users. They cannot be read by an application. If this field is set to true, the files are also uploaded as code data so your application can read them. Both uploads are charged against your code and static data storageresource quotas. This field isdeprecated in newer App Engine runtimes. |
expiration | 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 bed for days,h for hours,m for minutes, ands 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'sdefault_expiration is used. SeeCache expiration for more details. |
http_headers | Optional. You can setHTTP headers for responses of your static file or directory handlers. If you need to set HTTP headers in your handlers:-url:/imagesstatic_dir:static/imageshttp_headers:X-Foo-Header:fooX-Bar-Header:bar valuevary:Accept-Encoding# ... CORS SupportOne 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 Here is how you would make your static file handler return that required response header value: handlers:-url:/imagesstatic_dir:static/imageshttp_headers:Access-Control-Allow-Origin:https://mygame.uc.r.appspot.com# ... Note: if you wanted to allow everyone to access your assets, you could use the wildcard |
mime_type | 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, seethe IANA MIME Media Types website |
redirect_http_response_code | Optional.
handlers:-url:/youraccount/.*script:accounts.applogin:requiredsecure:alwaysredirect_http_response_code:301 When a user's request is redirected, the HTTP status code will be set to the value of the |
script | Optional. Specifies the path to the script from the application root directory: handlers:# The root URL (/) is handled by the WSGI application named# "app" in home.py. No other URLs match this pattern.-url:/script:home.app# The URL /index.html is also handled by the home.py script.-url:/index\.htmlscript:home.app# A regular expression can map parts of the URL to the# path of the script.-url:/browse/(books|videos|tools)script:\1.catalog.app# All other URLs use the WSGI application named in "app"# in not_found.py.-url:/.*script:not_found.app A Note: just like for a Python In newer App Engine runtimes,the the behavior of this field has changed. |
secure | Optional. Any URL handler can use thesecure setting, including script handlers and static file handlers. Thesecure element has the following possible values:
handlers:-url:/youraccount/.*script:accounts.applogin:requiredsecure:always The development web server does not support HTTPS connections. It ignores the To target a specific version of your app using the To use custom domains with HTTPS, you must first 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. |
static_dir | Optional. The path to the directory containing the static files, from the application root directory. Everything after the end of the matched Each file in the static directory is served using the MIME type that corresponds with its filename extension unless overridden by the directory's All files in this directory are uploaded with your app as static files. App Engine stores and serves static files separately from your app's files. Static files are not available in the app's file system by default. This can be changed by setting the handlers:# All URLs beginning with /stylesheets are treated as paths to# static files in the stylesheets/ directory.-url:/stylesheetsstatic_dir:stylesheets# ... |
static_files | 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 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/\1upload:static/.*\.(gif|png|jpg)$# ... App Engine stores and serves static files separately from application files. Static files are not available in the application's file system by default. This can be changed by setting the Static files cannot be the same as application code files. If a static file path matches a path to a script used in a dynamic handler, the script will not be available to the dynamic handler. |
upload | 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 | Required element under The URL pattern has some differences in behavior when used with the following elements:
|
Scaling elements
The elements in following table configure how your application scales. To learnmore about how App Engine apps scale, seeScaling types.
| Element | Description |
|---|---|
automatic_scaling | Optional. Applicable only for applications that use aninstance class 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:
automatic_scaling:target_cpu_utilization:0.65min_instances:5max_instances:100min_pending_latency:30msmax_pending_latency:automaticmax_concurrent_requests:50 |
basic_scaling | Applications that use aninstance class of B1 or higher must specify either this element or This element enables basic scaling of instance classes B1 and higher, can contain the following elements:
basic_scaling:max_instances:11idle_timeout:10m |
manual_scaling | Applications that use aninstance class of B1 or higher must specify either this element or This element enables manual scaling of instance classes B1 and higher, and can contain the following element:
manual_scaling:instances:5 |
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.