gcp.compute.TargetPool
Explore with Pulumi AI
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)
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v7/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
})
}
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 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.List;
import java.util.ArrayList;
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
Create TargetPool Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new TargetPool(name: string, args?: TargetPoolArgs, opts?: CustomResourceOptions);
@overload
def TargetPool(resource_name: str,
args: Optional[TargetPoolArgs] = None,
opts: Optional[ResourceOptions] = None)
@overload
def TargetPool(resource_name: str,
opts: Optional[ResourceOptions] = None,
backup_pool: Optional[str] = None,
description: Optional[str] = None,
failover_ratio: Optional[float] = None,
health_checks: Optional[str] = None,
instances: Optional[Sequence[str]] = None,
name: Optional[str] = None,
project: Optional[str] = None,
region: Optional[str] = None,
security_policy: Optional[str] = None,
session_affinity: Optional[str] = None)
func NewTargetPool(ctx *Context, name string, args *TargetPoolArgs, opts ...ResourceOption) (*TargetPool, error)
public TargetPool(string name, TargetPoolArgs? args = null, CustomResourceOptions? opts = null)
public TargetPool(String name, TargetPoolArgs args)
public TargetPool(String name, TargetPoolArgs args, CustomResourceOptions options)
type: gcp:compute:TargetPool
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 TargetPoolArgs
- 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 TargetPoolArgs
- 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 TargetPoolArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args TargetPoolArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args TargetPoolArgs
- 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 targetPoolResource = new Gcp.Compute.TargetPool("targetPoolResource", new()
{
BackupPool = "string",
Description = "string",
FailoverRatio = 0,
HealthChecks = "string",
Instances = new[]
{
"string",
},
Name = "string",
Project = "string",
Region = "string",
SecurityPolicy = "string",
SessionAffinity = "string",
});
example, err := compute.NewTargetPool(ctx, "targetPoolResource", &compute.TargetPoolArgs{
BackupPool: pulumi.String("string"),
Description: pulumi.String("string"),
FailoverRatio: pulumi.Float64(0),
HealthChecks: pulumi.String("string"),
Instances: pulumi.StringArray{
pulumi.String("string"),
},
Name: pulumi.String("string"),
Project: pulumi.String("string"),
Region: pulumi.String("string"),
SecurityPolicy: pulumi.String("string"),
SessionAffinity: pulumi.String("string"),
})
var targetPoolResource = new TargetPool("targetPoolResource", TargetPoolArgs.builder()
.backupPool("string")
.description("string")
.failoverRatio(0)
.healthChecks("string")
.instances("string")
.name("string")
.project("string")
.region("string")
.securityPolicy("string")
.sessionAffinity("string")
.build());
target_pool_resource = gcp.compute.TargetPool("targetPoolResource",
backup_pool="string",
description="string",
failover_ratio=0,
health_checks="string",
instances=["string"],
name="string",
project="string",
region="string",
security_policy="string",
session_affinity="string")
const targetPoolResource = new gcp.compute.TargetPool("targetPoolResource", {
backupPool: "string",
description: "string",
failoverRatio: 0,
healthChecks: "string",
instances: ["string"],
name: "string",
project: "string",
region: "string",
securityPolicy: "string",
sessionAffinity: "string",
});
type: gcp:compute:TargetPool
properties:
backupPool: string
description: string
failoverRatio: 0
healthChecks: string
instances:
- string
name: string
project: string
region: string
securityPolicy: string
sessionAffinity: string
TargetPool Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The TargetPool resource accepts the following input properties:
- Backup
Pool string - URL to the backup target pool. Must also set failover_ratio.
- Description string
- Textual description field.
- Failover
Ratio double - Ratio (0 to 1) of failed nodes before using the backup pool (which must also be set).
- Health
Checks string - List of zero or one health check name or self_link. Only
legacy
gcp.compute.HttpHealthCheck
is supported. - Instances 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.
- Name string
- A unique name for the resource, required by GCE. Changing
this forces a new resource to be created.
- Project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Region string
- Where the target pool resides. Defaults to project region.
- Security
Policy string - The resource URL for the security policy associated with this target pool.
- Session
Affinity 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").
- Backup
Pool string - URL to the backup target pool. Must also set failover_ratio.
- Description string
- Textual description field.
- Failover
Ratio float64 - Ratio (0 to 1) of failed nodes before using the backup pool (which must also be set).
- Health
Checks string - List of zero or one health check name or self_link. Only
legacy
gcp.compute.HttpHealthCheck
is supported. - Instances []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.
- Name string
- A unique name for the resource, required by GCE. Changing
this forces a new resource to be created.
- Project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Region string
- Where the target pool resides. Defaults to project region.
- Security
Policy string - The resource URL for the security policy associated with this target pool.
- Session
Affinity 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").
- backup
Pool String - URL to the backup target pool. Must also set failover_ratio.
- description String
- Textual description field.
- failover
Ratio Double - Ratio (0 to 1) of failed nodes before using the backup pool (which must also be set).
- health
Checks String - List of zero or one health check name or self_link. Only
legacy
gcp.compute.HttpHealthCheck
is supported. - instances 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.
- name String
- A unique name for the resource, required by GCE. Changing
this forces a new resource to be created.
- project String
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region String
- Where the target pool resides. Defaults to project region.
- security
Policy String - The resource URL for the security policy associated with this target pool.
- session
Affinity 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").
- backup
Pool string - URL to the backup target pool. Must also set failover_ratio.
- description string
- Textual description field.
- failover
Ratio number - Ratio (0 to 1) of failed nodes before using the backup pool (which must also be set).
- health
Checks string - List of zero or one health check name or self_link. Only
legacy
gcp.compute.HttpHealthCheck
is supported. - instances 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.
- name string
- A unique name for the resource, required by GCE. Changing
this forces a new resource to be created.
- project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region string
- Where the target pool resides. Defaults to project region.
- security
Policy string - The resource URL for the security policy associated with this target pool.
- session
Affinity 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").
- backup_
pool str - URL to the backup target pool. Must also set failover_ratio.
- description str
- Textual description field.
- failover_
ratio float - Ratio (0 to 1) of failed nodes before using the backup pool (which must also be set).
- health_
checks str - List of zero or one health check name or self_link. Only
legacy
gcp.compute.HttpHealthCheck
is supported. - instances Sequence[str]
- 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.
- name str
- A unique name for the resource, required by GCE. Changing
this forces a new resource to be created.
- project str
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region str
- Where the target pool resides. Defaults to project region.
- security_
policy str - The resource URL for the security policy associated with this target pool.
- session_
affinity str - 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").
- backup
Pool String - URL to the backup target pool. Must also set failover_ratio.
- description String
- Textual description field.
- failover
Ratio Number - Ratio (0 to 1) of failed nodes before using the backup pool (which must also be set).
- health
Checks String - List of zero or one health check name or self_link. Only
legacy
gcp.compute.HttpHealthCheck
is supported. - instances 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.
- name String
- A unique name for the resource, required by GCE. Changing
this forces a new resource to be created.
- project String
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region String
- Where the target pool resides. Defaults to project region.
- security
Policy String - The resource URL for the security policy associated with this target pool.
- session
Affinity 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").
Outputs
All input properties are implicitly available as output properties. Additionally, the TargetPool resource produces the following output properties:
Look up Existing TargetPool Resource
Get an existing TargetPool 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?: TargetPoolState, opts?: CustomResourceOptions): TargetPool
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
backup_pool: Optional[str] = None,
description: Optional[str] = None,
failover_ratio: Optional[float] = None,
health_checks: Optional[str] = None,
instances: Optional[Sequence[str]] = None,
name: Optional[str] = None,
project: Optional[str] = None,
region: Optional[str] = None,
security_policy: Optional[str] = None,
self_link: Optional[str] = None,
session_affinity: Optional[str] = None) -> TargetPool
func GetTargetPool(ctx *Context, name string, id IDInput, state *TargetPoolState, opts ...ResourceOption) (*TargetPool, error)
public static TargetPool Get(string name, Input<string> id, TargetPoolState? state, CustomResourceOptions? opts = null)
public static TargetPool get(String name, Output<String> id, TargetPoolState 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.
- Backup
Pool string - URL to the backup target pool. Must also set failover_ratio.
- Description string
- Textual description field.
- Failover
Ratio double - Ratio (0 to 1) of failed nodes before using the backup pool (which must also be set).
- Health
Checks string - List of zero or one health check name or self_link. Only
legacy
gcp.compute.HttpHealthCheck
is supported. - Instances 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.
- Name string
- A unique name for the resource, required by GCE. Changing
this forces a new resource to be created.
- Project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Region string
- Where the target pool resides. Defaults to project region.
- Security
Policy string - The resource URL for the security policy associated with this target pool.
- Self
Link string - The URI of the created resource.
- Session
Affinity 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").
- Backup
Pool string - URL to the backup target pool. Must also set failover_ratio.
- Description string
- Textual description field.
- Failover
Ratio float64 - Ratio (0 to 1) of failed nodes before using the backup pool (which must also be set).
- Health
Checks string - List of zero or one health check name or self_link. Only
legacy
gcp.compute.HttpHealthCheck
is supported. - Instances []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.
- Name string
- A unique name for the resource, required by GCE. Changing
this forces a new resource to be created.
- Project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Region string
- Where the target pool resides. Defaults to project region.
- Security
Policy string - The resource URL for the security policy associated with this target pool.
- Self
Link string - The URI of the created resource.
- Session
Affinity 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").
- backup
Pool String - URL to the backup target pool. Must also set failover_ratio.
- description String
- Textual description field.
- failover
Ratio Double - Ratio (0 to 1) of failed nodes before using the backup pool (which must also be set).
- health
Checks String - List of zero or one health check name or self_link. Only
legacy
gcp.compute.HttpHealthCheck
is supported. - instances 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.
- name String
- A unique name for the resource, required by GCE. Changing
this forces a new resource to be created.
- project String
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region String
- Where the target pool resides. Defaults to project region.
- security
Policy String - The resource URL for the security policy associated with this target pool.
- self
Link String - The URI of the created resource.
- session
Affinity 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").
- backup
Pool string - URL to the backup target pool. Must also set failover_ratio.
- description string
- Textual description field.
- failover
Ratio number - Ratio (0 to 1) of failed nodes before using the backup pool (which must also be set).
- health
Checks string - List of zero or one health check name or self_link. Only
legacy
gcp.compute.HttpHealthCheck
is supported. - instances 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.
- name string
- A unique name for the resource, required by GCE. Changing
this forces a new resource to be created.
- project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region string
- Where the target pool resides. Defaults to project region.
- security
Policy string - The resource URL for the security policy associated with this target pool.
- self
Link string - The URI of the created resource.
- session
Affinity 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").
- backup_
pool str - URL to the backup target pool. Must also set failover_ratio.
- description str
- Textual description field.
- failover_
ratio float - Ratio (0 to 1) of failed nodes before using the backup pool (which must also be set).
- health_
checks str - List of zero or one health check name or self_link. Only
legacy
gcp.compute.HttpHealthCheck
is supported. - instances Sequence[str]
- 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.
- name str
- A unique name for the resource, required by GCE. Changing
this forces a new resource to be created.
- project str
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region str
- Where the target pool resides. Defaults to project region.
- security_
policy str - The resource URL for the security policy associated with this target pool.
- self_
link str - The URI of the created resource.
- session_
affinity str - 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").
- backup
Pool String - URL to the backup target pool. Must also set failover_ratio.
- description String
- Textual description field.
- failover
Ratio Number - Ratio (0 to 1) of failed nodes before using the backup pool (which must also be set).
- health
Checks String - List of zero or one health check name or self_link. Only
legacy
gcp.compute.HttpHealthCheck
is supported. - instances 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.
- name String
- A unique name for the resource, required by GCE. Changing
this forces a new resource to be created.
- project String
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region String
- Where the target pool resides. Defaults to project region.
- security
Policy String - The resource URL for the security policy associated with this target pool.
- self
Link String - The URI of the created resource.
- session
Affinity 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").
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}}
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.