subcategory | description |
---|---|
App Engine |
Traffic routing configuration for versions within a single service. |
Traffic routing configuration for versions within a single service. Traffic splits define how traffic directed to the service is assigned to versions.
To get more information about ServiceSplitTraffic, see:
resource "google_storage_bucket" "bucket" {
name = "appengine-static-content"
location = "US"
}
resource "google_storage_bucket_object" "object" {
name = "hello-world.zip"
bucket = google_storage_bucket.bucket.name
source = "./test-fixtures/hello-world.zip"
}
resource "google_app_engine_standard_app_version" "liveapp_v1" {
version_id = "v1"
service = "liveapp"
delete_service_on_destroy = true
runtime = "nodejs20"
entrypoint {
shell = "node ./app.js"
}
deployment {
zip {
source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.object.name}"
}
}
env_variables = {
port = "8080"
}
}
resource "google_app_engine_standard_app_version" "liveapp_v2" {
version_id = "v2"
service = "liveapp"
noop_on_destroy = true
runtime = "nodejs20"
entrypoint {
shell = "node ./app.js"
}
deployment {
zip {
source_url = "https://storage.googleapis.com/${google_storage_bucket.bucket.name}/${google_storage_bucket_object.object.name}"
}
}
env_variables = {
port = "8080"
}
}
resource "google_app_engine_service_split_traffic" "liveapp" {
service = google_app_engine_standard_app_version.liveapp_v2.service
migrate_traffic = false
split {
shard_by = "IP"
allocations = {
(google_app_engine_standard_app_version.liveapp_v1.version_id) = 0.75
(google_app_engine_standard_app_version.liveapp_v2.version_id) = 0.25
}
}
}
The following arguments are supported:
-
service
- (Required) The name of the service these settings apply to. -
split
- (Required) Mapping that defines fractional HTTP traffic diversion to different versions within the service. Structure is documented below.
-
shard_by
- (Optional) Mechanism used to determine which version a request is sent to. The traffic selection algorithm will be stable for either type until allocations are changed. Possible values are:UNSPECIFIED
,COOKIE
,IP
,RANDOM
. -
allocations
- (Required) Mapping from version IDs within the service to fractional (0.000, 1] allocations of traffic for that version. Each version can be specified only once, but some versions in the service may not have any traffic allocation. Services that have traffic allocated cannot be deleted until either the service is deleted or their traffic allocation is removed. Allocations must sum to 1. Up to two decimal place precision is supported for IP-based splits and up to three decimal places is supported for cookie-based splits.
-
migrate_traffic
- (Optional) If set to true traffic will be migrated to this version. -
project
- (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
In addition to the arguments listed above, the following computed attributes are exported:
id
- an identifier for the resource with formatapps/{{project}}/services/{{service}}
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.update
- Default is 20 minutes.delete
- Default is 20 minutes.
ServiceSplitTraffic can be imported using any of these accepted formats:
apps/{{project}}/services/{{service}}
{{project}}/{{service}}
{{service}}
In Terraform v1.5.0 and later, use an import
block to import ServiceSplitTraffic using one of the formats above. For example:
import {
id = "apps/{{project}}/services/{{service}}"
to = google_app_engine_service_split_traffic.default
}
When using the terraform import
command, ServiceSplitTraffic can be imported using one of the formats above. For example:
$ terraform import google_app_engine_service_split_traffic.default apps/{{project}}/services/{{service}}
$ terraform import google_app_engine_service_split_traffic.default {{project}}/{{service}}
$ terraform import google_app_engine_service_split_traffic.default {{service}}
This resource supports User Project Overrides.