» google_app_engine_service_split_traffic

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:

» Example Usage - App Engine Service Split Traffic

resource "google_storage_bucket" "bucket" {
    name = "appengine-static-content"
}

resource "google_storage_bucket_object" "object" {
    name   = "hello-world.zip"
    bucket = google_storage_bucket.bucket.name
    source = "./test-fixtures/appengine/hello-world.zip"
}

resource "google_app_engine_standard_app_version" "liveapp_v1" {
  version_id = "v1"
  service = "liveapp"
  delete_service_on_destroy = true

  runtime = "nodejs10"
  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 = "nodejs10"
  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
    }
  }
}

» Argument Reference

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.

The split block supports:

  • 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.

» Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format apps/{{project}}/services/{{service}}

» Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 4 minutes.
  • update - Default is 4 minutes.
  • delete - Default is 4 minutes.

» Import

ServiceSplitTraffic can be imported using any of these accepted formats:

$ 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}}

» User Project Overrides

This resource supports User Project Overrides.