ServerGroup

class ServerGroup : KotlinCustomResource

Provides a NLB Server Group resource. For information about NLB Server Group and how to use it, see What is Server Group.

NOTE: Available since v1.186.0.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "tf-example";
const default = alicloud.resourcemanager.getResourceGroups({});
const defaultNetwork = new alicloud.vpc.Network("default", {
vpcName: name,
cidrBlock: "10.4.0.0/16",
});
const defaultServerGroup = new alicloud.nlb.ServerGroup("default", {
resourceGroupId: _default.then(_default => _default.ids?.[0]),
serverGroupName: name,
serverGroupType: "Instance",
vpcId: defaultNetwork.id,
scheduler: "Wrr",
protocol: "TCP",
connectionDrain: true,
connectionDrainTimeout: 60,
addressIpVersion: "Ipv4",
healthCheck: {
healthCheckEnabled: true,
healthCheckType: "TCP",
healthCheckConnectPort: 0,
healthyThreshold: 2,
unhealthyThreshold: 2,
healthCheckConnectTimeout: 5,
healthCheckInterval: 10,
httpCheckMethod: "GET",
healthCheckHttpCodes: [
"http_2xx",
"http_3xx",
"http_4xx",
],
},
tags: {
Created: "TF",
For: "example",
},
});
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "tf-example"
default = alicloud.resourcemanager.get_resource_groups()
default_network = alicloud.vpc.Network("default",
vpc_name=name,
cidr_block="10.4.0.0/16")
default_server_group = alicloud.nlb.ServerGroup("default",
resource_group_id=default.ids[0],
server_group_name=name,
server_group_type="Instance",
vpc_id=default_network.id,
scheduler="Wrr",
protocol="TCP",
connection_drain=True,
connection_drain_timeout=60,
address_ip_version="Ipv4",
health_check=alicloud.nlb.ServerGroupHealthCheckArgs(
health_check_enabled=True,
health_check_type="TCP",
health_check_connect_port=0,
healthy_threshold=2,
unhealthy_threshold=2,
health_check_connect_timeout=5,
health_check_interval=10,
http_check_method="GET",
health_check_http_codes=[
"http_2xx",
"http_3xx",
"http_4xx",
],
),
tags={
"Created": "TF",
"For": "example",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "tf-example";
var @default = AliCloud.ResourceManager.GetResourceGroups.Invoke();
var defaultNetwork = new AliCloud.Vpc.Network("default", new()
{
VpcName = name,
CidrBlock = "10.4.0.0/16",
});
var defaultServerGroup = new AliCloud.Nlb.ServerGroup("default", new()
{
ResourceGroupId = @default.Apply(@default => @default.Apply(getResourceGroupsResult => getResourceGroupsResult.Ids[0])),
ServerGroupName = name,
ServerGroupType = "Instance",
VpcId = defaultNetwork.Id,
Scheduler = "Wrr",
Protocol = "TCP",
ConnectionDrain = true,
ConnectionDrainTimeout = 60,
AddressIpVersion = "Ipv4",
HealthCheck = new AliCloud.Nlb.Inputs.ServerGroupHealthCheckArgs
{
HealthCheckEnabled = true,
HealthCheckType = "TCP",
HealthCheckConnectPort = 0,
HealthyThreshold = 2,
UnhealthyThreshold = 2,
HealthCheckConnectTimeout = 5,
HealthCheckInterval = 10,
HttpCheckMethod = "GET",
HealthCheckHttpCodes = new[]
{
"http_2xx",
"http_3xx",
"http_4xx",
},
},
Tags =
{
{ "Created", "TF" },
{ "For", "example" },
},
});
});
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/nlb"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/resourcemanager"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
name := "tf-example"
if param := cfg.Get("name"); param != "" {
name = param
}
_default, err := resourcemanager.GetResourceGroups(ctx, nil, nil)
if err != nil {
return err
}
defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
VpcName: pulumi.String(name),
CidrBlock: pulumi.String("10.4.0.0/16"),
})
if err != nil {
return err
}
_, err = nlb.NewServerGroup(ctx, "default", &nlb.ServerGroupArgs{
ResourceGroupId: pulumi.String(_default.Ids[0]),
ServerGroupName: pulumi.String(name),
ServerGroupType: pulumi.String("Instance"),
VpcId: defaultNetwork.ID(),
Scheduler: pulumi.String("Wrr"),
Protocol: pulumi.String("TCP"),
ConnectionDrain: pulumi.Bool(true),
ConnectionDrainTimeout: pulumi.Int(60),
AddressIpVersion: pulumi.String("Ipv4"),
HealthCheck: &nlb.ServerGroupHealthCheckArgs{
HealthCheckEnabled: pulumi.Bool(true),
HealthCheckType: pulumi.String("TCP"),
HealthCheckConnectPort: pulumi.Int(0),
HealthyThreshold: pulumi.Int(2),
UnhealthyThreshold: pulumi.Int(2),
HealthCheckConnectTimeout: pulumi.Int(5),
HealthCheckInterval: pulumi.Int(10),
HttpCheckMethod: pulumi.String("GET"),
HealthCheckHttpCodes: pulumi.StringArray{
pulumi.String("http_2xx"),
pulumi.String("http_3xx"),
pulumi.String("http_4xx"),
},
},
Tags: pulumi.Map{
"Created": pulumi.Any("TF"),
"For": pulumi.Any("example"),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.resourcemanager.ResourcemanagerFunctions;
import com.pulumi.alicloud.resourcemanager.inputs.GetResourceGroupsArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.nlb.ServerGroup;
import com.pulumi.alicloud.nlb.ServerGroupArgs;
import com.pulumi.alicloud.nlb.inputs.ServerGroupHealthCheckArgs;
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) {
final var config = ctx.config();
final var name = config.get("name").orElse("tf-example");
final var default = ResourcemanagerFunctions.getResourceGroups();
var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
.vpcName(name)
.cidrBlock("10.4.0.0/16")
.build());
var defaultServerGroup = new ServerGroup("defaultServerGroup", ServerGroupArgs.builder()
.resourceGroupId(default_.ids()[0])
.serverGroupName(name)
.serverGroupType("Instance")
.vpcId(defaultNetwork.id())
.scheduler("Wrr")
.protocol("TCP")
.connectionDrain(true)
.connectionDrainTimeout(60)
.addressIpVersion("Ipv4")
.healthCheck(ServerGroupHealthCheckArgs.builder()
.healthCheckEnabled(true)
.healthCheckType("TCP")
.healthCheckConnectPort(0)
.healthyThreshold(2)
.unhealthyThreshold(2)
.healthCheckConnectTimeout(5)
.healthCheckInterval(10)
.httpCheckMethod("GET")
.healthCheckHttpCodes(
"http_2xx",
"http_3xx",
"http_4xx")
.build())
.tags(Map.ofEntries(
Map.entry("Created", "TF"),
Map.entry("For", "example")
))
.build());
}
}
configuration:
name:
type: string
default: tf-example
resources:
defaultNetwork:
type: alicloud:vpc:Network
name: default
properties:
vpcName: ${name}
cidrBlock: 10.4.0.0/16
defaultServerGroup:
type: alicloud:nlb:ServerGroup
name: default
properties:
resourceGroupId: ${default.ids[0]}
serverGroupName: ${name}
serverGroupType: Instance
vpcId: ${defaultNetwork.id}
scheduler: Wrr
protocol: TCP
connectionDrain: true
connectionDrainTimeout: 60
addressIpVersion: Ipv4
healthCheck:
healthCheckEnabled: true
healthCheckType: TCP
healthCheckConnectPort: 0
healthyThreshold: 2
unhealthyThreshold: 2
healthCheckConnectTimeout: 5
healthCheckInterval: 10
httpCheckMethod: GET
healthCheckHttpCodes:
- http_2xx
- http_3xx
- http_4xx
tags:
Created: TF
For: example
variables:
default:
fn::invoke:
Function: alicloud:resourcemanager:getResourceGroups
Arguments: {}

Import

NLB Server Group can be imported using the id, e.g.

$ pulumi import alicloud:nlb/serverGroup:ServerGroup example <id>

Properties

Link copied to clipboard

The protocol version. Valid values: Ipv4 (default), DualStack.

Link copied to clipboard
val anyPortEnabled: Output<Boolean>

Full port forwarding.

Link copied to clipboard

. Field 'connection_drain' has been deprecated from provider version 1.214.0. New field 'connection_drain_enabled' instead.

Link copied to clipboard

Specifies whether to enable connection draining.

Link copied to clipboard

Set the connection elegant interrupt timeout. Unit: seconds. Valid values: 10 ~ 900.

Link copied to clipboard

Health check configuration information. See health_check below.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard

Indicates whether client address retention is enabled. Special instructions: When AddressIPVersion is of the ipv4 type, the default value is true. Addrestipversion can only be false when the value of ipv6 is ipv6, and can be true when supported by the underlying layer.

Link copied to clipboard
val protocol: Output<String>

The backend protocol. Valid values: TCP (default), UDP, and TCPSSL.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val resourceGroupId: Output<String>

The ID of the resource group to which the security group belongs.

Link copied to clipboard
val scheduler: Output<String>

The routing algorithm. Valid values:

Link copied to clipboard
val serverGroupName: Output<String>

The name of the server group. The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter.

Link copied to clipboard
val serverGroupType: Output<String>

The type of the server group. Valid values:

Link copied to clipboard
val status: Output<String>

Server group status. Value:

Link copied to clipboard
val tags: Output<Map<String, Any>>?

Label.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val vpcId: Output<String>

The ID of the VPC to which the server group belongs. The following arguments will be discarded. Please use new fields as soon as possible: