TargetPool class

Manages a Target Pool within GCE. This is a collection of instances used as target of a network load balancer (Forwarding Rule). For more information see the official documentation and API.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const defaultHttpHealthCheck = new gcp.compute.HttpHealthCheck("default", {
    name: "default",
    requestPath: "/",
    checkIntervalSec: 1,
    timeoutSec: 1,
});
const _default = new gcp.compute.TargetPool("default", {
    name: "instance-pool",
    instances: [
        "us-central1-a/myinstance1",
        "us-central1-b/myinstance2",
    ],
    healthChecks: defaultHttpHealthCheck.name,
});
import pulumi
import pulumi_gcp as gcp

default_http_health_check = gcp.compute.HttpHealthCheck("default",
    name="default",
    request_path="/",
    check_interval_sec=1,
    timeout_sec=1)
default = gcp.compute.TargetPool("default",
    name="instance-pool",
    instances=[
        "us-central1-a/myinstance1",
        "us-central1-b/myinstance2",
    ],
    health_checks=default_http_health_check.name)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() =>
{
    var defaultHttpHealthCheck = new Gcp.Compute.HttpHealthCheck("default", new()
    {
        Name = "default",
        RequestPath = "/",
        CheckIntervalSec = 1,
        TimeoutSec = 1,
    });

    var @default = new Gcp.Compute.TargetPool("default", new()
    {
        Name = "instance-pool",
        Instances = new[]
        {
            "us-central1-a/myinstance1",
            "us-central1-b/myinstance2",
        },
        HealthChecks = defaultHttpHealthCheck.Name,
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		defaultHttpHealthCheck, err := compute.NewHttpHealthCheck(ctx, "default", &compute.HttpHealthCheckArgs{
			Name:             pulumi.String("default"),
			RequestPath:      pulumi.String("/"),
			CheckIntervalSec: pulumi.Int(1),
			TimeoutSec:       pulumi.Int(1),
		})
		if err != nil {
			return err
		}
		_, err = compute.NewTargetPool(ctx, "default", &compute.TargetPoolArgs{
			Name: pulumi.String("instance-pool"),
			Instances: pulumi.StringArray{
				pulumi.String("us-central1-a/myinstance1"),
				pulumi.String("us-central1-b/myinstance2"),
			},
			HealthChecks: defaultHttpHealthCheck.Name,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    gcp = {
      source = "pulumi/gcp"
    }
  }
}

resource "gcp_compute_targetpool" "default" {
  name          = "instance-pool"
  instances     = ["us-central1-a/myinstance1", "us-central1-b/myinstance2"]
  health_checks = gcp_compute_httphealthcheck.default.name
}
resource "gcp_compute_httphealthcheck" "default" {
  name               = "default"
  request_path       = "/"
  check_interval_sec = 1
  timeout_sec        = 1
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.HttpHealthCheck;
import com.pulumi.gcp.compute.HttpHealthCheckArgs;
import com.pulumi.gcp.compute.TargetPool;
import com.pulumi.gcp.compute.TargetPoolArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var defaultHttpHealthCheck = new HttpHealthCheck("defaultHttpHealthCheck", HttpHealthCheckArgs.builder()
            .name("default")
            .requestPath("/")
            .checkIntervalSec(1)
            .timeoutSec(1)
            .build());

        var default_ = new TargetPool("default", TargetPoolArgs.builder()
            .name("instance-pool")
            .instances(
                "us-central1-a/myinstance1",
                "us-central1-b/myinstance2")
            .healthChecks(defaultHttpHealthCheck.name())
            .build());

    }
}
resources:
  default:
    type: gcp:compute:TargetPool
    properties:
      name: instance-pool
      instances:
        - us-central1-a/myinstance1
        - us-central1-b/myinstance2
      healthChecks: ${defaultHttpHealthCheck.name}
  defaultHttpHealthCheck:
    type: gcp:compute:HttpHealthCheck
    name: default
    properties:
      name: default
      requestPath: /
      checkIntervalSec: 1
      timeoutSec: 1

Import

Target pools can be imported using any of the following formats:

  • projects/{{project}}/regions/{{region}}/targetPools/{{name}}
  • {{project}}/{{region}}/{{name}}
  • {{region}}/{{name}}
  • {{name}}

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

$ pulumi import gcp:compute/targetPool:TargetPool default projects/{{project}}/regions/{{region}}/targetPools/{{name}}
$ pulumi import gcp:compute/targetPool:TargetPool default {{project}}/{{region}}/{{name}}
$ pulumi import gcp:compute/targetPool:TargetPool default {{region}}/{{name}}
$ pulumi import gcp:compute/targetPool:TargetPool default {{name}}

Constructors

TargetPool(String name, {TargetPoolArgs? args, CustomResourceOptions? options})
Creates a new TargetPool. name The Pulumi resource name. args Arguments used to configure this TargetPool. The set of arguments for TargetPool. options Resource options controlling this resource's behavior.
TargetPool.reference(String urn)
Creates a typed reference to an existing TargetPool resource.

Properties

backupPool ↔ Output<String?>
URL to the backup target pool. Must also set failover_ratio.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
deletionPolicy ↔ Output<String>
Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". When a 'terraform destroy' or 'pulumi up' would delete the resource, the command will fail if this field is set to "PREVENT" in Terraform state. When set to "ABANDON", the command will remove the resource from Terraform management without updating or deleting the resource in the API. When set to "DELETE", deleting the resource is allowed.
latefinal
description ↔ Output<String?>
Textual description field.
latefinal
failoverRatio ↔ Output<double?>
Ratio (0 to 1) of failed nodes before using the backup pool (which must also be set).
latefinal
hashCode → int
The hash code for this object.
no setterinherited
healthChecks ↔ Output<String?>
List of zero or one health check name or self_link. Only legacy gcp.compute.HttpHealthCheck is supported.
latefinal
id ↔ Output<String>
getter/setter pairinherited
instances ↔ Output<List<String>>
List of instances in the pool. They can be given as URLs, or in the form of "zone/name". Note that the instances need not exist at the time of target pool creation, so there is no need to use the interpolation to create a dependency on the instances from the target pool.
latefinal
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
name ↔ Output<String>
A unique name for the resource, required by GCE. Changing this forces a new resource to be created.
latefinal
project ↔ Output<String>
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
latefinal
region ↔ Output<String>
Where the target pool resides. Defaults to project region.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
securityPolicy ↔ Output<String?>
) The resource URL for the security policy associated with this target pool.
latefinal
The URI of the created resource.
latefinal
sessionAffinity ↔ Output<String?>
How to distribute load. Options are "NONE" (no affinity). "CLIENT_IP" (hash of the source/dest addresses / ports), and "CLIENT_IP_PROTO" also includes the protocol (default "NONE").
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {TargetPoolState? state, CustomResourceOptions? options}) → TargetPool
Gets an existing TargetPool resource's state with the given name and id.