1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. appengine
  5. EngineSplitTraffic
Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi

gcp.appengine.EngineSplitTraffic

Explore with Pulumi AI

gcp logo
Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi

    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

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const bucket = new gcp.storage.Bucket("bucket", {
        name: "appengine-static-content",
        location: "US",
    });
    const object = new gcp.storage.BucketObject("object", {
        name: "hello-world.zip",
        bucket: bucket.name,
        source: new pulumi.asset.FileAsset("./test-fixtures/hello-world.zip"),
    });
    const liveappV1 = new gcp.appengine.StandardAppVersion("liveapp_v1", {
        versionId: "v1",
        service: "liveapp",
        deleteServiceOnDestroy: true,
        runtime: "nodejs20",
        entrypoint: {
            shell: "node ./app.js",
        },
        deployment: {
            zip: {
                sourceUrl: pulumi.interpolate`https://storage.googleapis.com/${bucket.name}/${object.name}`,
            },
        },
        envVariables: {
            port: "8080",
        },
    });
    const liveappV2 = new gcp.appengine.StandardAppVersion("liveapp_v2", {
        versionId: "v2",
        service: "liveapp",
        noopOnDestroy: true,
        runtime: "nodejs20",
        entrypoint: {
            shell: "node ./app.js",
        },
        deployment: {
            zip: {
                sourceUrl: pulumi.interpolate`https://storage.googleapis.com/${bucket.name}/${object.name}`,
            },
        },
        envVariables: {
            port: "8080",
        },
    });
    const liveapp = new gcp.appengine.EngineSplitTraffic("liveapp", {
        service: liveappV2.service,
        migrateTraffic: false,
        split: {
            shardBy: "IP",
            allocations: pulumi.all([liveappV1.versionId, liveappV2.versionId]).apply(([liveappV1VersionId, liveappV2VersionId]) => {
                [liveappV1VersionId]: 0.75,
                [liveappV2VersionId]: 0.25,
            }),
        },
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    bucket = gcp.storage.Bucket("bucket",
        name="appengine-static-content",
        location="US")
    object = gcp.storage.BucketObject("object",
        name="hello-world.zip",
        bucket=bucket.name,
        source=pulumi.FileAsset("./test-fixtures/hello-world.zip"))
    liveapp_v1 = gcp.appengine.StandardAppVersion("liveapp_v1",
        version_id="v1",
        service="liveapp",
        delete_service_on_destroy=True,
        runtime="nodejs20",
        entrypoint={
            "shell": "node ./app.js",
        },
        deployment={
            "zip": {
                "source_url": pulumi.Output.all(
                    bucketName=bucket.name,
                    objectName=object.name
    ).apply(lambda resolved_outputs: f"https://storage.googleapis.com/{resolved_outputs['bucketName']}/{resolved_outputs['objectName']}")
    ,
            },
        },
        env_variables={
            "port": "8080",
        })
    liveapp_v2 = gcp.appengine.StandardAppVersion("liveapp_v2",
        version_id="v2",
        service="liveapp",
        noop_on_destroy=True,
        runtime="nodejs20",
        entrypoint={
            "shell": "node ./app.js",
        },
        deployment={
            "zip": {
                "source_url": pulumi.Output.all(
                    bucketName=bucket.name,
                    objectName=object.name
    ).apply(lambda resolved_outputs: f"https://storage.googleapis.com/{resolved_outputs['bucketName']}/{resolved_outputs['objectName']}")
    ,
            },
        },
        env_variables={
            "port": "8080",
        })
    liveapp = gcp.appengine.EngineSplitTraffic("liveapp",
        service=liveapp_v2.service,
        migrate_traffic=False,
        split={
            "shard_by": "IP",
            "allocations": pulumi.Output.all(
                liveappV1Version_id=liveapp_v1.version_id,
                liveappV2Version_id=liveapp_v2.version_id
    ).apply(lambda resolved_outputs: {
                resolved_outputs['liveappV1Version_id']: 0.75,
                resolved_outputs['liveappV2Version_id']: 0.25,
            })
    ,
        })
    
    Coming soon!
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var bucket = new Gcp.Storage.Bucket("bucket", new()
        {
            Name = "appengine-static-content",
            Location = "US",
        });
    
        var @object = new Gcp.Storage.BucketObject("object", new()
        {
            Name = "hello-world.zip",
            Bucket = bucket.Name,
            Source = new FileAsset("./test-fixtures/hello-world.zip"),
        });
    
        var liveappV1 = new Gcp.AppEngine.StandardAppVersion("liveapp_v1", new()
        {
            VersionId = "v1",
            Service = "liveapp",
            DeleteServiceOnDestroy = true,
            Runtime = "nodejs20",
            Entrypoint = new Gcp.AppEngine.Inputs.StandardAppVersionEntrypointArgs
            {
                Shell = "node ./app.js",
            },
            Deployment = new Gcp.AppEngine.Inputs.StandardAppVersionDeploymentArgs
            {
                Zip = new Gcp.AppEngine.Inputs.StandardAppVersionDeploymentZipArgs
                {
                    SourceUrl = Output.Tuple(bucket.Name, @object.Name).Apply(values =>
                    {
                        var bucketName = values.Item1;
                        var objectName = values.Item2;
                        return $"https://storage.googleapis.com/{bucketName}/{objectName}";
                    }),
                },
            },
            EnvVariables = 
            {
                { "port", "8080" },
            },
        });
    
        var liveappV2 = new Gcp.AppEngine.StandardAppVersion("liveapp_v2", new()
        {
            VersionId = "v2",
            Service = "liveapp",
            NoopOnDestroy = true,
            Runtime = "nodejs20",
            Entrypoint = new Gcp.AppEngine.Inputs.StandardAppVersionEntrypointArgs
            {
                Shell = "node ./app.js",
            },
            Deployment = new Gcp.AppEngine.Inputs.StandardAppVersionDeploymentArgs
            {
                Zip = new Gcp.AppEngine.Inputs.StandardAppVersionDeploymentZipArgs
                {
                    SourceUrl = Output.Tuple(bucket.Name, @object.Name).Apply(values =>
                    {
                        var bucketName = values.Item1;
                        var objectName = values.Item2;
                        return $"https://storage.googleapis.com/{bucketName}/{objectName}";
                    }),
                },
            },
            EnvVariables = 
            {
                { "port", "8080" },
            },
        });
    
        var liveapp = new Gcp.AppEngine.EngineSplitTraffic("liveapp", new()
        {
            Service = liveappV2.Service,
            MigrateTraffic = false,
            Split = new Gcp.AppEngine.Inputs.EngineSplitTrafficSplitArgs
            {
                ShardBy = "IP",
                Allocations = Output.Tuple(liveappV1.VersionId, liveappV2.VersionId).Apply(values =>
                {
                    var liveappV1VersionId = values.Item1;
                    var liveappV2VersionId = values.Item2;
                    return 
                    {
                        { liveappV1VersionId, 0.75 },
                        { liveappV2VersionId, 0.25 },
                    };
                }),
            },
        });
    
    });
    
    Coming soon!
    
    resources:
      bucket:
        type: gcp:storage:Bucket
        properties:
          name: appengine-static-content
          location: US
      object:
        type: gcp:storage:BucketObject
        properties:
          name: hello-world.zip
          bucket: ${bucket.name}
          source:
            fn::FileAsset: ./test-fixtures/hello-world.zip
      liveappV1:
        type: gcp:appengine:StandardAppVersion
        name: liveapp_v1
        properties:
          versionId: v1
          service: liveapp
          deleteServiceOnDestroy: true
          runtime: nodejs20
          entrypoint:
            shell: node ./app.js
          deployment:
            zip:
              sourceUrl: https://storage.googleapis.com/${bucket.name}/${object.name}
          envVariables:
            port: '8080'
      liveappV2:
        type: gcp:appengine:StandardAppVersion
        name: liveapp_v2
        properties:
          versionId: v2
          service: liveapp
          noopOnDestroy: true
          runtime: nodejs20
          entrypoint:
            shell: node ./app.js
          deployment:
            zip:
              sourceUrl: https://storage.googleapis.com/${bucket.name}/${object.name}
          envVariables:
            port: '8080'
      liveapp:
        type: gcp:appengine:EngineSplitTraffic
        properties:
          service: ${liveappV2.service}
          migrateTraffic: false
          split:
            shardBy: IP
            allocations:
              ${liveappV1.versionId}: 0.75
              ${liveappV2.versionId}: 0.25
    

    Create EngineSplitTraffic Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new EngineSplitTraffic(name: string, args: EngineSplitTrafficArgs, opts?: CustomResourceOptions);
    @overload
    def EngineSplitTraffic(resource_name: str,
                           args: EngineSplitTrafficArgs,
                           opts: Optional[ResourceOptions] = None)
    
    @overload
    def EngineSplitTraffic(resource_name: str,
                           opts: Optional[ResourceOptions] = None,
                           service: Optional[str] = None,
                           split: Optional[EngineSplitTrafficSplitArgs] = None,
                           migrate_traffic: Optional[bool] = None,
                           project: Optional[str] = None)
    func NewEngineSplitTraffic(ctx *Context, name string, args EngineSplitTrafficArgs, opts ...ResourceOption) (*EngineSplitTraffic, error)
    public EngineSplitTraffic(string name, EngineSplitTrafficArgs args, CustomResourceOptions? opts = null)
    public EngineSplitTraffic(String name, EngineSplitTrafficArgs args)
    public EngineSplitTraffic(String name, EngineSplitTrafficArgs args, CustomResourceOptions options)
    
    type: gcp:appengine:EngineSplitTraffic
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args EngineSplitTrafficArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args EngineSplitTrafficArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args EngineSplitTrafficArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args EngineSplitTrafficArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args EngineSplitTrafficArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var engineSplitTrafficResource = new Gcp.AppEngine.EngineSplitTraffic("engineSplitTrafficResource", new()
    {
        Service = "string",
        Split = new Gcp.AppEngine.Inputs.EngineSplitTrafficSplitArgs
        {
            Allocations = 
            {
                { "string", "string" },
            },
            ShardBy = "string",
        },
        MigrateTraffic = false,
        Project = "string",
    });
    
    example, err := appengine.NewEngineSplitTraffic(ctx, "engineSplitTrafficResource", &appengine.EngineSplitTrafficArgs{
    	Service: pulumi.String("string"),
    	Split: &appengine.EngineSplitTrafficSplitArgs{
    		Allocations: pulumi.StringMap{
    			"string": pulumi.String("string"),
    		},
    		ShardBy: pulumi.String("string"),
    	},
    	MigrateTraffic: pulumi.Bool(false),
    	Project:        pulumi.String("string"),
    })
    
    var engineSplitTrafficResource = new EngineSplitTraffic("engineSplitTrafficResource", EngineSplitTrafficArgs.builder()
        .service("string")
        .split(EngineSplitTrafficSplitArgs.builder()
            .allocations(Map.of("string", "string"))
            .shardBy("string")
            .build())
        .migrateTraffic(false)
        .project("string")
        .build());
    
    engine_split_traffic_resource = gcp.appengine.EngineSplitTraffic("engineSplitTrafficResource",
        service="string",
        split={
            "allocations": {
                "string": "string",
            },
            "shard_by": "string",
        },
        migrate_traffic=False,
        project="string")
    
    const engineSplitTrafficResource = new gcp.appengine.EngineSplitTraffic("engineSplitTrafficResource", {
        service: "string",
        split: {
            allocations: {
                string: "string",
            },
            shardBy: "string",
        },
        migrateTraffic: false,
        project: "string",
    });
    
    type: gcp:appengine:EngineSplitTraffic
    properties:
        migrateTraffic: false
        project: string
        service: string
        split:
            allocations:
                string: string
            shardBy: string
    

    EngineSplitTraffic Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The EngineSplitTraffic resource accepts the following input properties:

    Service string
    The name of the service these settings apply to.
    Split EngineSplitTrafficSplit
    Mapping that defines fractional HTTP traffic diversion to different versions within the service. Structure is documented below.
    MigrateTraffic bool
    If set to true traffic will be migrated to this version.
    Project string
    Service string
    The name of the service these settings apply to.
    Split EngineSplitTrafficSplitArgs
    Mapping that defines fractional HTTP traffic diversion to different versions within the service. Structure is documented below.
    MigrateTraffic bool
    If set to true traffic will be migrated to this version.
    Project string
    service String
    The name of the service these settings apply to.
    split EngineSplitTrafficSplit
    Mapping that defines fractional HTTP traffic diversion to different versions within the service. Structure is documented below.
    migrateTraffic Boolean
    If set to true traffic will be migrated to this version.
    project String
    service string
    The name of the service these settings apply to.
    split EngineSplitTrafficSplit
    Mapping that defines fractional HTTP traffic diversion to different versions within the service. Structure is documented below.
    migrateTraffic boolean
    If set to true traffic will be migrated to this version.
    project string
    service str
    The name of the service these settings apply to.
    split EngineSplitTrafficSplitArgs
    Mapping that defines fractional HTTP traffic diversion to different versions within the service. Structure is documented below.
    migrate_traffic bool
    If set to true traffic will be migrated to this version.
    project str
    service String
    The name of the service these settings apply to.
    split Property Map
    Mapping that defines fractional HTTP traffic diversion to different versions within the service. Structure is documented below.
    migrateTraffic Boolean
    If set to true traffic will be migrated to this version.
    project String

    Outputs

    All input properties are implicitly available as output properties. Additionally, the EngineSplitTraffic resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing EngineSplitTraffic Resource

    Get an existing EngineSplitTraffic resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: EngineSplitTrafficState, opts?: CustomResourceOptions): EngineSplitTraffic
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            migrate_traffic: Optional[bool] = None,
            project: Optional[str] = None,
            service: Optional[str] = None,
            split: Optional[EngineSplitTrafficSplitArgs] = None) -> EngineSplitTraffic
    func GetEngineSplitTraffic(ctx *Context, name string, id IDInput, state *EngineSplitTrafficState, opts ...ResourceOption) (*EngineSplitTraffic, error)
    public static EngineSplitTraffic Get(string name, Input<string> id, EngineSplitTrafficState? state, CustomResourceOptions? opts = null)
    public static EngineSplitTraffic get(String name, Output<String> id, EngineSplitTrafficState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    MigrateTraffic bool
    If set to true traffic will be migrated to this version.
    Project string
    Service string
    The name of the service these settings apply to.
    Split EngineSplitTrafficSplit
    Mapping that defines fractional HTTP traffic diversion to different versions within the service. Structure is documented below.
    MigrateTraffic bool
    If set to true traffic will be migrated to this version.
    Project string
    Service string
    The name of the service these settings apply to.
    Split EngineSplitTrafficSplitArgs
    Mapping that defines fractional HTTP traffic diversion to different versions within the service. Structure is documented below.
    migrateTraffic Boolean
    If set to true traffic will be migrated to this version.
    project String
    service String
    The name of the service these settings apply to.
    split EngineSplitTrafficSplit
    Mapping that defines fractional HTTP traffic diversion to different versions within the service. Structure is documented below.
    migrateTraffic boolean
    If set to true traffic will be migrated to this version.
    project string
    service string
    The name of the service these settings apply to.
    split EngineSplitTrafficSplit
    Mapping that defines fractional HTTP traffic diversion to different versions within the service. Structure is documented below.
    migrate_traffic bool
    If set to true traffic will be migrated to this version.
    project str
    service str
    The name of the service these settings apply to.
    split EngineSplitTrafficSplitArgs
    Mapping that defines fractional HTTP traffic diversion to different versions within the service. Structure is documented below.
    migrateTraffic Boolean
    If set to true traffic will be migrated to this version.
    project String
    service String
    The name of the service these settings apply to.
    split Property Map
    Mapping that defines fractional HTTP traffic diversion to different versions within the service. Structure is documented below.

    Supporting Types

    EngineSplitTrafficSplit, EngineSplitTrafficSplitArgs

    Allocations Dictionary<string, string>
    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.


    ShardBy string
    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 map[string]string
    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.


    ShardBy string
    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 Map<String,String>
    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.


    shardBy String
    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 {[key: string]: string}
    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.


    shardBy string
    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 Mapping[str, str]
    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.


    shard_by str
    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 Map<String>
    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.


    shardBy String
    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.

    Import

    ServiceSplitTraffic can be imported using any of these accepted formats:

    • apps/{{project}}/services/{{service}}

    • {{project}}/{{service}}

    • {{service}}

    When using the pulumi import command, ServiceSplitTraffic can be imported using one of the formats above. For example:

    $ pulumi import gcp:appengine/engineSplitTraffic:EngineSplitTraffic default apps/{{project}}/services/{{service}}
    
    $ pulumi import gcp:appengine/engineSplitTraffic:EngineSplitTraffic default {{project}}/{{service}}
    
    $ pulumi import gcp:appengine/engineSplitTraffic:EngineSplitTraffic default {{service}}
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Google Cloud (GCP) Classic pulumi/pulumi-gcp
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the google-beta Terraform Provider.
    gcp logo
    Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi