| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** AUTO GENERATED CODE *** Type: MMv1 *** |
| # |
| # ---------------------------------------------------------------------------- |
| # |
| # This file is automatically generated by Magic Modules and manual |
| # changes will be clobbered when the file is regenerated. |
| # |
| # Please read more about how to change this file in |
| # .github/CONTRIBUTING.md. |
| # |
| # ---------------------------------------------------------------------------- |
| subcategory: "App Engine" |
| description: |- |
| Traffic routing configuration for versions within a single service. |
| --- |
| |
| # 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: |
| |
| * [API documentation](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services) |
| |
| ## Example Usage - App Engine Service Split Traffic |
| |
| |
| ```hcl |
| 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 = "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](#nested_split). |
| |
| |
| <a name="nested_split"></a>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](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: |
| |
| - `create` - Default is 20 minutes. |
| - `update` - Default is 20 minutes. |
| - `delete` - Default is 20 minutes. |
| |
| ## Import |
| |
| |
| 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](https://developer.hashicorp.com/terraform/language/import) to import ServiceSplitTraffic using one of the formats above. For example: |
| |
| ```tf |
| import { |
| id = "apps/{{project}}/services/{{service}}" |
| to = google_app_engine_service_split_traffic.default |
| } |
| ``` |
| |
| When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), 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](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). |