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

Argument Reference

The following arguments are supported:

The split block supports:


Attributes Reference

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

Timeouts

This resource provides the following Timeouts configuration options:

Import

ServiceSplitTraffic can be imported using any of these accepted formats:

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

User Project Overrides

This resource supports User Project Overrides.