Google App Engine Flexible App Version
This page shows how to write Terraform for App Engine Flexible App Version and write them securely.
google_app_engine_flexible_app_version (Terraform)
The Flexible App Version in App Engine can be configured in Terraform with the resource name google_app_engine_flexible_app_version. The following sections describe 3 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "google_app_engine_flexible_app_version" "flexible_app" {
count = ""
runtime = ""
version_id = ""
inbound_services = []
instance_class = ""
resource "google_app_engine_flexible_app_version" "default_app" {
count = var.create_default_service ? 1 : 0
service = "default"
version_id = "mlflow-default"
runtime = "custom"
resource "google_app_engine_flexible_app_version" "first_app" {
version_id = "v1"
project = "gcptutorials"
service = "kafka-service"
runtime = "custom"
Parameters
-
beta_settingsoptional - map from string to string
Metadata settings that are supplied to this version to enable beta runtime features.
-
default_expirationoptional - string
Duration that static files should be cached by web proxies and browsers. Only applicable if the corresponding StaticFilesHandler does not specify its own expiration time.
-
delete_service_on_destroyoptional - bool -
env_variablesoptional - map from string to string
Environment variables available to the application. As these are not returned in the API request, Terraform will not detect any changes made outside of the Terraform config.
-
idoptional computed - string -
inbound_servicesoptional - set of string
A list of the types of messages that this application is able to receive. Possible values: ["INBOUND_SERVICE_MAIL", "INBOUND_SERVICE_MAIL_BOUNCE", "INBOUND_SERVICE_XMPP_ERROR", "INBOUND_SERVICE_XMPP_MESSAGE", "INBOUND_SERVICE_XMPP_SUBSCRIBE", "INBOUND_SERVICE_XMPP_PRESENCE", "INBOUND_SERVICE_CHANNEL_PRESENCE", "INBOUND_SERVICE_WARMUP"]
-
instance_classoptional - string
Instance class that is used to run this version. Valid values are AutomaticScaling: F1, F2, F4, F4_1G ManualScaling: B1, B2, B4, B8, B4_1G Defaults to F1 for AutomaticScaling and B1 for ManualScaling.
-
nameoptional computed - string
Full path to the Version resource in the API. Example, "v1".
-
nobuild_files_regexoptional - string
Files that match this pattern will not be built into this version. Only applicable for Go runtimes.
-
noop_on_destroyoptional - bool -
projectoptional computed - string -
runtimerequired - string
Desired runtime. Example python27.
-
runtime_api_versionoptional computed - string
The version of the API in the given runtime environment. Please see the app.yaml reference for valid values at https://cloud.google.com/appengine/docs/standard//config/appref
-
runtime_channeloptional - string
The channel of the runtime to use. Only available for some runtimes.
-
runtime_main_executable_pathoptional - string
The path or name of the app's main executable.
-
servicerequired - string
AppEngine service resource
-
serving_statusoptional - string
Current serving status of this version. Only the versions with a SERVING status create instances and can be billed. Default value: "SERVING" Possible values: ["SERVING", "STOPPED"]
-
version_idoptional - string
Relative name of the version within the service. For example, 'v1'. Version names can contain only lowercase letters, numbers, or hyphens. Reserved names,"default", "latest", and any name with the prefix "ah-".
-
api_configlist block-
auth_fail_actionoptional - string
Action to take when users access resources that require authentication. Default value: "AUTH_FAIL_ACTION_REDIRECT" Possible values: ["AUTH_FAIL_ACTION_REDIRECT", "AUTH_FAIL_ACTION_UNAUTHORIZED"]
-
loginoptional - string
Level of login required to access this resource. Default value: "LOGIN_OPTIONAL" Possible values: ["LOGIN_OPTIONAL", "LOGIN_ADMIN", "LOGIN_REQUIRED"]
-
scriptrequired - string
Path to the script from the application root directory.
-
security_leveloptional - string
Security (HTTPS) enforcement for this URL. Possible values: ["SECURE_DEFAULT", "SECURE_NEVER", "SECURE_OPTIONAL", "SECURE_ALWAYS"]
-
urloptional - string
URL to serve the endpoint at.
-
-
automatic_scalinglist block-
cool_down_periodoptional - string
The time period that the Autoscaler should wait before it starts collecting information from a new instance. This prevents the autoscaler from collecting information when the instance is initializing, during which the collected usage would not be reliable. Default: 120s
-
max_concurrent_requestsoptional computed - number
Number of concurrent requests an automatic scaling instance can accept before the scheduler spawns a new instance. Defaults to a runtime-specific value.
-
max_idle_instancesoptional - number
Maximum number of idle instances that should be maintained for this version.
-
max_pending_latencyoptional - string
Maximum amount of time that a request should wait in the pending queue before starting a new instance to handle it.
-
max_total_instancesoptional - number
Maximum number of instances that should be started to handle requests for this version. Default: 20
-
min_idle_instancesoptional - number
Minimum number of idle instances that should be maintained for this version. Only applicable for the default version of a service.
-
min_pending_latencyoptional - string
Minimum amount of time a request should wait in the pending queue before starting a new instance to handle it.
-
min_total_instancesoptional - number
Minimum number of running instances that should be maintained for this version. Default: 2
-
cpu_utilizationlist block-
aggregation_window_lengthoptional - string
Period of time over which CPU utilization is calculated.
-
target_utilizationrequired - number
Target CPU utilization ratio to maintain when scaling. Must be between 0 and 1.
-
-
disk_utilizationlist block-
target_read_bytes_per_secondoptional - number
Target bytes read per second.
-
target_read_ops_per_secondoptional - number
Target ops read per seconds.
-
target_write_bytes_per_secondoptional - number
Target bytes written per second.
-
target_write_ops_per_secondoptional - number
Target ops written per second.
-
-
network_utilizationlist block-
target_received_bytes_per_secondoptional - number
Target bytes received per second.
-
target_received_packets_per_secondoptional - number
Target packets received per second.
-
target_sent_bytes_per_secondoptional - number
Target bytes sent per second.
-
target_sent_packets_per_secondoptional - number
Target packets sent per second.
-
-
request_utilizationlist block-
target_concurrent_requestsoptional - number
Target number of concurrent requests.
-
target_request_count_per_secondoptional - string
Target requests per second.
-
-
-
deploymentlist block-
cloud_build_optionslist block-
app_yaml_pathrequired - string
Path to the yaml file used in deployment, used to determine runtime configuration details.
-
cloud_build_timeoutoptional - string
The Cloud Build timeout used as part of any dependent builds performed by version creation. Defaults to 10 minutes. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".
-
-
containerlist block-
imagerequired - string
URI to the hosted container image in Google Container Registry. The URI must be fully qualified and include a tag or digest. Examples: "gcr.io/my-project/image:tag" or "gcr.io/my-project/image@digest"
-
-
filesset blockSHA1 checksum of the file
-
source_urlrequired - string
Source URL
-
-
ziplist block-
files_countoptional - number
files count
-
source_urlrequired - string
Source URL
-
-
-
endpoints_api_servicelist block-
config_idoptional - string
Endpoints service configuration ID as specified by the Service Management API. For example "2016-09-19r1". By default, the rollout strategy for Endpoints is "FIXED". This means that Endpoints starts up with a particular configuration ID. When a new configuration is rolled out, Endpoints must be given the new configuration ID. The configId field is used to give the configuration ID and is required in this case. Endpoints also has a rollout strategy called "MANAGED". When using this, Endpoints fetches the latest configuration and does not need the configuration ID. In this case, configId must be omitted.
-
disable_trace_samplingoptional - bool
Enable or disable trace sampling. By default, this is set to false for enabled.
-
namerequired - string
Endpoints service name which is the name of the "service" resource in the Service Management API. For example "myapi.endpoints.myproject.cloud.goog"
-
rollout_strategyoptional - string
Endpoints rollout strategy. If FIXED, configId must be specified. If MANAGED, configId must be omitted. Default value: "FIXED" Possible values: ["FIXED", "MANAGED"]
-
-
entrypointlist block-
shellrequired - string
The format should be a shell command that can be fed to bash -c.
-
-
handlerslist block-
auth_fail_actionoptional - string
Actions to take when the user is not logged in. Possible values: ["AUTH_FAIL_ACTION_REDIRECT", "AUTH_FAIL_ACTION_UNAUTHORIZED"]
-
loginoptional - string
Methods to restrict access to a URL based on login status. Possible values: ["LOGIN_OPTIONAL", "LOGIN_ADMIN", "LOGIN_REQUIRED"]
-
redirect_http_response_codeoptional - string
30x code to use when performing redirects for the secure field. Possible values: ["REDIRECT_HTTP_RESPONSE_CODE_301", "REDIRECT_HTTP_RESPONSE_CODE_302", "REDIRECT_HTTP_RESPONSE_CODE_303", "REDIRECT_HTTP_RESPONSE_CODE_307"]
-
security_leveloptional - string
Security (HTTPS) enforcement for this URL. Possible values: ["SECURE_DEFAULT", "SECURE_NEVER", "SECURE_OPTIONAL", "SECURE_ALWAYS"]
-
url_regexoptional - string
URL prefix. Uses regular expression syntax, which means regexp special characters must be escaped, but should not contain groupings. 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.
-
scriptlist block-
script_pathrequired - string
Path to the script from the application root directory.
-
-
static_fileslist block-
application_readableoptional - bool
Whether files should also be uploaded as code data. 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 the application. If enabled, uploads are charged against both your code and static data storage resource quotas.
-
expirationoptional - string
Time a static file served by this handler should be cached by web proxies and browsers. A duration in seconds with up to nine fractional digits, terminated by 's'. Example "3.5s". Default is '0s'
-
http_headersoptional - map from string to string
HTTP headers to use for all responses from these URLs. An object containing a list of "key:value" value pairs.".
-
mime_typeoptional - string
MIME type used to serve all files served by this handler. Defaults to file-specific MIME types, which are derived from each file's filename extension.
-
pathoptional - string
Path to the static files matched by the URL pattern, from the application root directory. The path can refer to text matched in groupings in the URL pattern.
-
require_matching_fileoptional - bool
Whether this handler should match the request if the file referenced by the handler does not exist.
-
upload_path_regexoptional - string
Regular expression that matches the file paths for all files that should be referenced by this handler.
-
-
-
liveness_checklist block-
check_intervaloptional - string
Interval between health checks.
-
failure_thresholdoptional - number
Number of consecutive failed checks required before considering the VM unhealthy. Default: 4.
-
hostoptional - string
Host header to send when performing a HTTP Readiness check. Example: "myapp.appspot.com"
-
initial_delayoptional - string
The initial delay before starting to execute the checks. Default: "300s"
-
pathrequired - string
The request path.
-
success_thresholdoptional - number
Number of consecutive successful checks required before considering the VM healthy. Default: 2.
-
timeoutoptional - string
Time before the check is considered failed. Default: "4s"
-
-
manual_scalinglist block-
instancesrequired - number
Number of instances to assign to the service at the start. Note: When managing the number of instances at runtime through the App Engine Admin API or the (now deprecated) Python 2 Modules API set_num_instances() you must use 'lifecycle.ignore_changes = ["manual_scaling"[0].instances]' to prevent drift detection.
-
-
networklist block-
forwarded_portsoptional - list of string
List of ports, or port pairs, to forward from the virtual machine to the application container.
-
instance_tagoptional - string
Tag to apply to the instance during creation.
-
namerequired - string
Google Compute Engine network where the virtual machines are created. Specify the short name, not the resource path.
-
session_affinityoptional - bool
Enable session affinity.
-
subnetworkoptional - string
Google Cloud Platform sub-network where the virtual machines are created. Specify the short name, not the resource path. If the network that the instance is being created in is a Legacy network, then the IP address is allocated from the IPv4Range. If the network that the instance is being created in is an auto Subnet Mode Network, then only network name should be specified (not the subnetworkName) and the IP address is created from the IPCidrRange of the subnetwork that exists in that zone for that network. If the network that the instance is being created in is a custom Subnet Mode Network, then the subnetworkName must be specified and the IP address is created from the IPCidrRange of the subnetwork. If specified, the subnetwork must exist in the same region as the App Engine flexible environment application.
-
-
readiness_checklist block-
app_start_timeoutoptional - string
A maximum time limit on application initialization, measured from moment the application successfully replies to a healthcheck until it is ready to serve traffic. Default: "300s"
-
check_intervaloptional - string
Interval between health checks. Default: "5s".
-
failure_thresholdoptional - number
Number of consecutive failed checks required before removing traffic. Default: 2.
-
hostoptional - string
Host header to send when performing a HTTP Readiness check. Example: "myapp.appspot.com"
-
pathrequired - string
The request path.
-
success_thresholdoptional - number
Number of consecutive successful checks required before receiving traffic. Default: 2.
-
timeoutoptional - string
Time before the check is considered failed. Default: "4s"
-
-
resourceslist block-
cpuoptional - number
Number of CPU cores needed.
-
disk_gboptional - number
Disk size (GB) needed.
-
memory_gboptional - number
Memory (GB) needed.
-
volumeslist block-
namerequired - string
Unique name for the volume.
-
size_gbrequired - number
Volume size in gigabytes.
-
volume_typerequired - string
Underlying volume type, e.g. 'tmpfs'.
-
-
-
timeoutssingle block -
vpc_access_connectorlist block-
namerequired - string
Full Serverless VPC Access Connector name e.g. /projects/my-project/locations/us-central1/connectors/c1.
-
Explanation in Terraform Registry
Flexible App Version resource to create a new version of flexible GAE Application. Based on Google Compute Engine, the App Engine flexible environment automatically scales your app up and down while also balancing the load. Learn about the differences between the standard environment and the flexible environment at https://cloud.google.com/appengine/docs/the-appengine-environments.
Note: The App Engine flexible environment service account uses the member ID
service-[YOUR_PROJECT_NUMBER]@gae-api-prod.google.com.iam.gserviceaccount.comIt should have the App Engine Flexible Environment Service Agent role, which will be applied when theappengineflex.googleapis.comservice is enabled. To get more information about FlexibleAppVersion, see:
- API documentation
- How-to Guides
Frequently asked questions
What is Google App Engine Flexible App Version?
Google App Engine Flexible App Version is a resource for App Engine of Google Cloud Platform. Settings can be wrote in Terraform.
Where can I find the example code for the Google App Engine Flexible App Version?
For Terraform, the mikamakusa/terraform, artefactory-global/one-click-mlflow and AnudeepKonaboina/GoogleCloudPlatform source code examples are useful. See the Terraform Example section for further details.