googleAppEngineStandardAppVersion
Standard App Version resource to create a new version of standard GAE Application. Learn about the differences between the standard environment and the flexible environment at https://cloud.google.com/appengine/docs/the-appengine-environments. Currently supporting Zip and File Containers.
To get more information about StandardAppVersion, see:
- API documentation
- How-to Guides
- Official Documentation
Example Usage - App Engine Standard App Version
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleServiceAccountCustomServiceAccount =
new google.serviceAccount.ServiceAccount(this, "custom_service_account", {
account_id: "my-account",
display_name: "Custom Service Account",
});
const googleStorageBucketBucket = new google.storageBucket.StorageBucket(
this,
"bucket",
{
location: "US",
name: "appengine-static-content",
}
);
const googleStorageBucketObjectObject =
new google.storageBucketObject.StorageBucketObject(this, "object", {
bucket: googleStorageBucketBucket.name,
name: "hello-world.zip",
source: "./test-fixtures/appengine/hello-world.zip",
});
new google.appEngineStandardAppVersion.AppEngineStandardAppVersion(
this,
"myapp_v1",
{
automatic_scaling: [
{
max_concurrent_requests: 10,
max_idle_instances: 3,
max_pending_latency: "5s",
min_idle_instances: 1,
min_pending_latency: "1s",
standard_scheduler_settings: [
{
max_instances: 10,
min_instances: 2,
target_cpu_utilization: 0.5,
target_throughput_utilization: 0.75,
},
],
},
],
delete_service_on_destroy: true,
deployment: [
{
zip: [
{
source_url: `https://storage.googleapis.com/\${${googleStorageBucketBucket.name}}/\${${googleStorageBucketObjectObject.name}}`,
},
],
},
],
entrypoint: [
{
shell: "node ./app.js",
},
],
env_variables: [
{
port: "8080",
},
],
runtime: "nodejs10",
service: "myapp",
service_account: googleServiceAccountCustomServiceAccount.email,
version_id: "v1",
}
);
new google.appEngineStandardAppVersion.AppEngineStandardAppVersion(
this,
"myapp_v2",
{
app_engine_apis: true,
basic_scaling: [
{
max_instances: 5,
},
],
deployment: [
{
zip: [
{
source_url: `https://storage.googleapis.com/\${${googleStorageBucketBucket.name}}/\${${googleStorageBucketObjectObject.name}}`,
},
],
},
],
entrypoint: [
{
shell: "node ./app.js",
},
],
env_variables: [
{
port: "8080",
},
],
noop_on_destroy: true,
runtime: "nodejs10",
service: "myapp",
service_account: googleServiceAccountCustomServiceAccount.email,
version_id: "v2",
}
);
new google.projectIamMember.ProjectIamMember(this, "gae_api", {
member: `serviceAccount:\${${googleServiceAccountCustomServiceAccount.email}}`,
project: googleServiceAccountCustomServiceAccount.project,
role: "roles/compute.networkUser",
});
new google.projectIamMember.ProjectIamMember(this, "storage_viewer", {
member: `serviceAccount:\${${googleServiceAccountCustomServiceAccount.email}}`,
project: googleServiceAccountCustomServiceAccount.project,
role: "roles/storage.objectViewer",
});
Argument Reference
The following arguments are supported:
-
runtime
- (Required) Desired runtime. Example python27. -
deployment
- (Required) Code and application artifacts that make up this version. Structure is documented below. -
entrypoint
- (Required) The entrypoint for the application. Structure is documented below. -
service
- (Required) AppEngine service resource
The deployment
block supports:
-
zip
- (Optional) Zip File Structure is documented below. -
files
- (Optional) Manifest of the files stored in Google Cloud Storage that are included as part of this version. All files must be readable using the credentials supplied with this call. Structure is documented below.
-
sourceUrl
- (Required) Source URL -
filesCount
- (Optional) files count
-
name
- (Required) The identifier for this object. Format specified above. -
sha1Sum
- (Optional) SHA1 checksum of the file -
sourceUrl
- (Required) Source URL
The entrypoint
block supports:
shell
- (Required) The format should be a shell command that can be fed to bash -c.
-
versionId
- (Optional) 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-". -
serviceAccount
- (Optional) The identity that the deployed version will run as. Admin API will use the App Engine Appspot service account as default if this field is neither provided in app.yaml file nor through CLI flag. -
threadsafe
- (Optional) Whether multiple requests can be dispatched to this version at once. -
appEngineApis
- (Optional) Allows App Engine second generation runtimes to access the legacy bundled services. -
runtimeApiVersion
- (Optional) The version of the API in the given runtime environment. Please see the app.yaml reference for valid values athttps://cloudGoogleCom/appengine/docs/standard/<language>/config/appref
\ Substitute<language>
withpython
,java
,php
,ruby
,go
ornodejs
. -
handlers
- (Optional) An ordered list of URL-matching patterns that should be applied to incoming requests. The first matching URL handles the request and other request handlers are not attempted. Structure is documented below. -
libraries
- (Optional) Configuration for third-party Python runtime libraries that are required by the application. Structure is documented below. -
envVariables
- (Optional) Environment variables available to the application. -
vpcAccessConnector
- (Optional) Enables VPC connectivity for standard apps. Structure is documented below. -
inboundServices
- (Optional) A list of the types of messages that this application is able to receive. Each value may be one ofinboundServiceMail
,inboundServiceMailBounce
,inboundServiceXmppError
,inboundServiceXmppMessage
,inboundServiceXmppSubscribe
,inboundServiceXmppPresence
,inboundServiceChannelPresence
, andinboundServiceWarmup
. -
instanceClass
- (Optional) Instance class that is used to run this version. Valid values are AutomaticScaling: F1, F2, F4, F4_1G BasicScaling or ManualScaling: B1, B2, B4, B4_1G, B8 Defaults to F1 for AutomaticScaling and B2 for ManualScaling and BasicScaling. If no scaling is specified, AutomaticScaling is chosen. -
automaticScaling
- (Optional) Automatic scaling is based on request rate, response latencies, and other application metrics. Structure is documented below. -
basicScaling
- (Optional) Basic scaling creates instances when your application receives requests. Each instance will be shut down when the application becomes idle. Basic scaling is ideal for work that is intermittent or driven by user activity. Structure is documented below. -
manualScaling
- (Optional) A service with manual scaling runs continuously, allowing you to perform complex initialization and rely on the state of its memory over time. Structure is documented below. -
project
- (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used. -
noopOnDestroy
- (Optional) If set totrue
, the application version will not be deleted. -
deleteServiceOnDestroy
- (Optional) If set totrue
, the service will be deleted if it is the last version.
-
urlRegex
- (Optional) 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. -
securityLevel
- (Optional) Security (HTTPS) enforcement for this URL. Possible values aresecureDefault
,secureNever
,secureOptional
, andsecureAlways
. -
login
- (Optional) Methods to restrict access to a URL based on login status. Possible values areloginOptional
,loginAdmin
, andloginRequired
. -
authFailAction
- (Optional) Actions to take when the user is not logged in. Possible values areauthFailActionRedirect
andauthFailActionUnauthorized
. -
redirectHttpResponseCode
- (Optional) 30x code to use when performing redirects for the secure field. Possible values areredirectHttpResponseCode301
,redirectHttpResponseCode302
,redirectHttpResponseCode303
, andredirectHttpResponseCode307
. -
script
- (Optional) Executes a script to handle the requests that match this URL pattern. Only the auto value is supported for Node.js in the App Engine standard environment, for example "script:" "auto". Structure is documented below. -
staticFiles
- (Optional) Files served directly to the user for a given URL, such as images, CSS stylesheets, or JavaScript source files. Static file handlers describe which files in the application directory are static files, and which URLs serve them. Structure is documented below.
scriptPath
- (Required) Path to the script from the application root directory.
The staticFiles
block supports:
-
path
- (Optional) 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. -
uploadPathRegex
- (Optional) Regular expression that matches the file paths for all files that should be referenced by this handler. -
httpHeaders
- (Optional) HTTP headers to use for all responses from these URLs. An object containing a list of "key:value" value pairs.". -
mimeType
- (Optional) 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. -
expiration
- (Optional) 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". -
requireMatchingFile
- (Optional) Whether this handler should match the request if the file referenced by the handler does not exist. -
applicationReadable
- (Optional) 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.
-
name
- (Optional) Name of the library. Example "django". -
version
- (Optional) Version of the library to select, or "latest".
The vpcAccessConnector
block supports:
-
name
- (Required) Full Serverless VPC Access Connector name e.g. /projects/my-project/locations/us-central1/connectors/c1. -
egressSetting
- (Optional) The egress setting for the connector, controlling what traffic is diverted through it.
The automaticScaling
block supports:
-
maxConcurrentRequests
- (Optional) Number of concurrent requests an automatic scaling instance can accept before the scheduler spawns a new instance. Defaults to a runtime-specific value. -
maxIdleInstances
- (Optional) Maximum number of idle instances that should be maintained for this version. -
maxPendingLatency
- (Optional) Maximum amount of time that a request should wait in the pending queue before starting a new instance to handle it. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s". -
minIdleInstances
- (Optional) Minimum number of idle instances that should be maintained for this version. Only applicable for the default version of a service. -
minPendingLatency
- (Optional) Minimum amount of time a request should wait in the pending queue before starting a new instance to handle it. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s". -
standardSchedulerSettings
- (Optional) Scheduler settings for standard environment. Structure is documented below.
The standardSchedulerSettings
block supports:
-
targetCpuUtilization
- (Optional) Target CPU utilization ratio to maintain when scaling. Should be a value in the range [0.50, 0.95], zero, or a negative value. -
targetThroughputUtilization
- (Optional) Target throughput utilization ratio to maintain when scaling. Should be a value in the range [0.50, 0.95], zero, or a negative value. -
minInstances
- (Optional) Minimum number of instances to run for this version. Set to zero to disable minInstances configuration. -
maxInstances
- (Optional) Maximum number of instances to run for this version. Set to zero to disable maxInstances configuration.
The basicScaling
block supports:
-
idleTimeout
- (Optional) Duration of time after the last request that an instance must wait before the instance is shut down. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s". Defaults to 900s. -
maxInstances
- (Required) Maximum number of instances to create for this version. Must be in the range [1.0, 200.0].
The manualScaling
block supports:
instances
- (Required) 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 uselifecycleIgnoreChanges = ["manualScaling"[0]Instances]
to prevent drift detection.
Attributes Reference
In addition to the arguments listed above, the following computed attributes are exported:
-
id
- an identifier for the resource with formatapps/{{project}}/services/{{service}}/versions/{{versionId}}
-
name
- Full path to the Version resource in the API. Example, "v1".
Timeouts
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.update
- Default is 20 minutes.delete
- Default is 20 minutes.
Import
StandardAppVersion can be imported using any of these accepted formats:
$ terraform import google_app_engine_standard_app_version.default apps/{{project}}/services/{{service}}/versions/{{version_id}}
$ terraform import google_app_engine_standard_app_version.default {{project}}/{{service}}/{{version_id}}
$ terraform import google_app_engine_standard_app_version.default {{service}}/{{version_id}}
User Project Overrides
This resource supports User Project Overrides.