getServerGroups

This data source provides the VServer groups related to a server load balancer.

Example Usage

using Pulumi;
using AliCloud = Pulumi.AliCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var config = new Config();
        var name = config.Get("name") ?? "slbservergroups";
        var defaultZones = Output.Create(AliCloud.GetZones.InvokeAsync(new AliCloud.GetZonesArgs
        {
            AvailableDiskCategory = "cloud_efficiency",
            AvailableResourceCreation = "VSwitch",
        }));
        var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new AliCloud.Vpc.NetworkArgs
        {
            VpcName = name,
            CidrBlock = "172.16.0.0/16",
        });
        var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new AliCloud.Vpc.SwitchArgs
        {
            VpcId = defaultNetwork.Id,
            CidrBlock = "172.16.0.0/16",
            ZoneId = defaultZones.Apply(defaultZones => defaultZones.Zones?[0]?.Id),
            VswitchName = name,
        });
        var defaultApplicationLoadBalancer = new AliCloud.Slb.ApplicationLoadBalancer("defaultApplicationLoadBalancer", new AliCloud.Slb.ApplicationLoadBalancerArgs
        {
            LoadBalancerName = name,
            VswitchId = defaultSwitch.Id,
        });
        var defaultServerGroup = new AliCloud.Slb.ServerGroup("defaultServerGroup", new AliCloud.Slb.ServerGroupArgs
        {
            LoadBalancerId = defaultApplicationLoadBalancer.Id,
        });
        var sampleDs = AliCloud.Slb.GetServerGroups.Invoke(new AliCloud.Slb.GetServerGroupsInvokeArgs
        {
            LoadBalancerId = defaultApplicationLoadBalancer.Id,
        });
        this.FirstSlbServerGroupId = sampleDs.Apply(sampleDs => sampleDs.SlbServerGroups?[0]?.Id);
    }

    [Output("firstSlbServerGroupId")]
    public Output<string> FirstSlbServerGroupId { get; set; }
}
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/slb"
	"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 := "slbservergroups"
		if param := cfg.Get("name"); param != "" {
			name = param
		}
		defaultZones, err := alicloud.GetZones(ctx, &GetZonesArgs{
			AvailableDiskCategory:     pulumi.StringRef("cloud_efficiency"),
			AvailableResourceCreation: pulumi.StringRef("VSwitch"),
		}, nil)
		if err != nil {
			return err
		}
		defaultNetwork, err := vpc.NewNetwork(ctx, "defaultNetwork", &vpc.NetworkArgs{
			VpcName:   pulumi.String(name),
			CidrBlock: pulumi.String("172.16.0.0/16"),
		})
		if err != nil {
			return err
		}
		defaultSwitch, err := vpc.NewSwitch(ctx, "defaultSwitch", &vpc.SwitchArgs{
			VpcId:       defaultNetwork.ID(),
			CidrBlock:   pulumi.String("172.16.0.0/16"),
			ZoneId:      pulumi.String(defaultZones.Zones[0].Id),
			VswitchName: pulumi.String(name),
		})
		if err != nil {
			return err
		}
		defaultApplicationLoadBalancer, err := slb.NewApplicationLoadBalancer(ctx, "defaultApplicationLoadBalancer", &slb.ApplicationLoadBalancerArgs{
			LoadBalancerName: pulumi.String(name),
			VswitchId:        defaultSwitch.ID(),
		})
		if err != nil {
			return err
		}
		_, err = slb.NewServerGroup(ctx, "defaultServerGroup", &slb.ServerGroupArgs{
			LoadBalancerId: defaultApplicationLoadBalancer.ID(),
		})
		if err != nil {
			return err
		}
		sampleDs := slb.GetServerGroupsOutput(ctx, slb.GetServerGroupsOutputArgs{
			LoadBalancerId: defaultApplicationLoadBalancer.ID(),
		}, nil)
		ctx.Export("firstSlbServerGroupId", sampleDs.ApplyT(func(sampleDs slb.GetServerGroupsResult) (string, error) {
			return sampleDs.SlbServerGroups[0].Id, nil
		}).(pulumi.StringOutput))
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.adb.inputs.GetZonesArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.slb.ApplicationLoadBalancer;
import com.pulumi.alicloud.slb.ApplicationLoadBalancerArgs;
import com.pulumi.alicloud.slb.ServerGroup;
import com.pulumi.alicloud.slb.ServerGroupArgs;
import com.pulumi.alicloud.slb.SlbFunctions;
import com.pulumi.alicloud.alb.inputs.GetServerGroupsArgs;
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("slbservergroups");
        final var defaultZones = AlicloudFunctions.getZones(GetZonesArgs.builder()
            .availableDiskCategory("cloud_efficiency")
            .availableResourceCreation("VSwitch")
            .build());

        var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()        
            .vpcName(name)
            .cidrBlock("172.16.0.0/16")
            .build());

        var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()        
            .vpcId(defaultNetwork.id())
            .cidrBlock("172.16.0.0/16")
            .zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
            .vswitchName(name)
            .build());

        var defaultApplicationLoadBalancer = new ApplicationLoadBalancer("defaultApplicationLoadBalancer", ApplicationLoadBalancerArgs.builder()        
            .loadBalancerName(name)
            .vswitchId(defaultSwitch.id())
            .build());

        var defaultServerGroup = new ServerGroup("defaultServerGroup", ServerGroupArgs.builder()        
            .loadBalancerId(defaultApplicationLoadBalancer.id())
            .build());

        final var sampleDs = SlbFunctions.getServerGroups(GetServerGroupsArgs.builder()
            .loadBalancerId(defaultApplicationLoadBalancer.id())
            .build());

        ctx.export("firstSlbServerGroupId", sampleDs.applyValue(getServerGroupsResult -> getServerGroupsResult).applyValue(sampleDs -> sampleDs.applyValue(getServerGroupsResult -> getServerGroupsResult.slbServerGroups()[0].id())));
    }
}
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "slbservergroups"
default_zones = alicloud.get_zones(available_disk_category="cloud_efficiency",
    available_resource_creation="VSwitch")
default_network = alicloud.vpc.Network("defaultNetwork",
    vpc_name=name,
    cidr_block="172.16.0.0/16")
default_switch = alicloud.vpc.Switch("defaultSwitch",
    vpc_id=default_network.id,
    cidr_block="172.16.0.0/16",
    zone_id=default_zones.zones[0].id,
    vswitch_name=name)
default_application_load_balancer = alicloud.slb.ApplicationLoadBalancer("defaultApplicationLoadBalancer",
    load_balancer_name=name,
    vswitch_id=default_switch.id)
default_server_group = alicloud.slb.ServerGroup("defaultServerGroup", load_balancer_id=default_application_load_balancer.id)
sample_ds = alicloud.slb.get_server_groups_output(load_balancer_id=default_application_load_balancer.id)
pulumi.export("firstSlbServerGroupId", sample_ds.slb_server_groups[0].id)
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const config = new pulumi.Config();
const name = config.get("name") || "slbservergroups";
const defaultZones = alicloud.getZones({
    availableDiskCategory: "cloud_efficiency",
    availableResourceCreation: "VSwitch",
});
const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {
    vpcName: name,
    cidrBlock: "172.16.0.0/16",
});
const defaultSwitch = new alicloud.vpc.Switch("defaultSwitch", {
    vpcId: defaultNetwork.id,
    cidrBlock: "172.16.0.0/16",
    zoneId: defaultZones.then(defaultZones => defaultZones.zones?[0]?.id),
    vswitchName: name,
});
const defaultApplicationLoadBalancer = new alicloud.slb.ApplicationLoadBalancer("defaultApplicationLoadBalancer", {
    loadBalancerName: name,
    vswitchId: defaultSwitch.id,
});
const defaultServerGroup = new alicloud.slb.ServerGroup("defaultServerGroup", {loadBalancerId: defaultApplicationLoadBalancer.id});
const sampleDs = alicloud.slb.getServerGroupsOutput({
    loadBalancerId: defaultApplicationLoadBalancer.id,
});
export const firstSlbServerGroupId = sampleDs.apply(sampleDs => sampleDs.slbServerGroups?[0]?.id);
configuration:
  name:
    type: string
    default: slbservergroups
resources:
  defaultNetwork:
    type: alicloud:vpc:Network
    properties:
      vpcName: ${name}
      cidrBlock: 172.16.0.0/16
  defaultSwitch:
    type: alicloud:vpc:Switch
    properties:
      vpcId: ${defaultNetwork.id}
      cidrBlock: 172.16.0.0/16
      zoneId: ${defaultZones.zones[0].id}
      vswitchName: ${name}
  defaultApplicationLoadBalancer:
    type: alicloud:slb:ApplicationLoadBalancer
    properties:
      loadBalancerName: ${name}
      vswitchId: ${defaultSwitch.id}
  defaultServerGroup:
    type: alicloud:slb:ServerGroup
    properties:
      loadBalancerId: ${defaultApplicationLoadBalancer.id}
variables:
  defaultZones:
    Fn::Invoke:
      Function: alicloud:getZones
      Arguments:
        availableDiskCategory: cloud_efficiency
        availableResourceCreation: VSwitch
  sampleDs:
    Fn::Invoke:
      Function: alicloud:slb:getServerGroups
      Arguments:
        loadBalancerId: ${defaultApplicationLoadBalancer.id}
outputs:
  firstSlbServerGroupId: ${sampleDs.slbServerGroups[0].id}

Using getServerGroups

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getServerGroups(args: GetServerGroupsArgs, opts?: InvokeOptions): Promise<GetServerGroupsResult>
function getServerGroupsOutput(args: GetServerGroupsOutputArgs, opts?: InvokeOptions): Output<GetServerGroupsResult>
def get_server_groups(ids: Optional[Sequence[str]] = None,
                      load_balancer_id: Optional[str] = None,
                      name_regex: Optional[str] = None,
                      output_file: Optional[str] = None,
                      opts: Optional[InvokeOptions] = None) -> GetServerGroupsResult
def get_server_groups_output(ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                      load_balancer_id: Optional[pulumi.Input[str]] = None,
                      name_regex: Optional[pulumi.Input[str]] = None,
                      output_file: Optional[pulumi.Input[str]] = None,
                      opts: Optional[InvokeOptions] = None) -> Output[GetServerGroupsResult]
func GetServerGroups(ctx *Context, args *GetServerGroupsArgs, opts ...InvokeOption) (*GetServerGroupsResult, error)
func GetServerGroupsOutput(ctx *Context, args *GetServerGroupsOutputArgs, opts ...InvokeOption) GetServerGroupsResultOutput

> Note: This function is named GetServerGroups in the Go SDK.

public static class GetServerGroups 
{
    public static Task<GetServerGroupsResult> InvokeAsync(GetServerGroupsArgs args, InvokeOptions? opts = null)
    public static Output<GetServerGroupsResult> Invoke(GetServerGroupsInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetServerGroupsResult> getServerGroups(GetServerGroupsArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: alicloud:slb/getServerGroups:getServerGroups
  arguments:
    # arguments dictionary

The following arguments are supported:

LoadBalancerId string

ID of the SLB.

Ids List<string>

A list of VServer group IDs to filter results.

NameRegex string

A regex string to filter results by VServer group name.

OutputFile string
LoadBalancerId string

ID of the SLB.

Ids []string

A list of VServer group IDs to filter results.

NameRegex string

A regex string to filter results by VServer group name.

OutputFile string
loadBalancerId String

ID of the SLB.

ids List<String>

A list of VServer group IDs to filter results.

nameRegex String

A regex string to filter results by VServer group name.

outputFile String
loadBalancerId string

ID of the SLB.

ids string[]

A list of VServer group IDs to filter results.

nameRegex string

A regex string to filter results by VServer group name.

outputFile string
load_balancer_id str

ID of the SLB.

ids Sequence[str]

A list of VServer group IDs to filter results.

name_regex str

A regex string to filter results by VServer group name.

output_file str
loadBalancerId String

ID of the SLB.

ids List<String>

A list of VServer group IDs to filter results.

nameRegex String

A regex string to filter results by VServer group name.

outputFile String

getServerGroups Result

The following output properties are available:

Id string

The provider-assigned unique ID for this managed resource.

Ids List<string>

A list of SLB VServer groups IDs.

LoadBalancerId string
Names List<string>

A list of SLB VServer groups names.

SlbServerGroups List<Pulumi.AliCloud.Slb.Outputs.GetServerGroupsSlbServerGroup>

A list of SLB VServer groups. Each element contains the following attributes:

NameRegex string
OutputFile string
Id string

The provider-assigned unique ID for this managed resource.

Ids []string

A list of SLB VServer groups IDs.

LoadBalancerId string
Names []string

A list of SLB VServer groups names.

SlbServerGroups []GetServerGroupsSlbServerGroup

A list of SLB VServer groups. Each element contains the following attributes:

NameRegex string
OutputFile string
id String

The provider-assigned unique ID for this managed resource.

ids List<String>

A list of SLB VServer groups IDs.

loadBalancerId String
names List<String>

A list of SLB VServer groups names.

slbServerGroups List<GetServerGroupsSlbServerGroup>

A list of SLB VServer groups. Each element contains the following attributes:

nameRegex String
outputFile String
id string

The provider-assigned unique ID for this managed resource.

ids string[]

A list of SLB VServer groups IDs.

loadBalancerId string
names string[]

A list of SLB VServer groups names.

slbServerGroups GetServerGroupsSlbServerGroup[]

A list of SLB VServer groups. Each element contains the following attributes:

nameRegex string
outputFile string
id str

The provider-assigned unique ID for this managed resource.

ids Sequence[str]

A list of SLB VServer groups IDs.

load_balancer_id str
names Sequence[str]

A list of SLB VServer groups names.

slb_server_groups Sequence[GetServerGroupsSlbServerGroup]

A list of SLB VServer groups. Each element contains the following attributes:

name_regex str
output_file str
id String

The provider-assigned unique ID for this managed resource.

ids List<String>

A list of SLB VServer groups IDs.

loadBalancerId String
names List<String>

A list of SLB VServer groups names.

slbServerGroups List<Property Map>

A list of SLB VServer groups. Each element contains the following attributes:

nameRegex String
outputFile String

Supporting Types

GetServerGroupsSlbServerGroup

Id string

VServer group ID.

Name string

VServer group name.

Servers List<Pulumi.AliCloud.Slb.Inputs.GetServerGroupsSlbServerGroupServer>

ECS instances associated to the group. Each element contains the following attributes:

Id string

VServer group ID.

Name string

VServer group name.

Servers []GetServerGroupsSlbServerGroupServer

ECS instances associated to the group. Each element contains the following attributes:

id String

VServer group ID.

name String

VServer group name.

servers List<GetServerGroupsSlbServerGroupServer>

ECS instances associated to the group. Each element contains the following attributes:

id string

VServer group ID.

name string

VServer group name.

servers GetServerGroupsSlbServerGroupServer[]

ECS instances associated to the group. Each element contains the following attributes:

id str

VServer group ID.

name str

VServer group name.

servers Sequence[GetServerGroupsSlbServerGroupServer]

ECS instances associated to the group. Each element contains the following attributes:

id String

VServer group ID.

name String

VServer group name.

servers List<Property Map>

ECS instances associated to the group. Each element contains the following attributes:

GetServerGroupsSlbServerGroupServer

InstanceId string

ID of the attached ECS instance.

Weight int

Weight associated to the ECS instance.

InstanceId string

ID of the attached ECS instance.

Weight int

Weight associated to the ECS instance.

instanceId String

ID of the attached ECS instance.

weight Integer

Weight associated to the ECS instance.

instanceId string

ID of the attached ECS instance.

weight number

Weight associated to the ECS instance.

instance_id str

ID of the attached ECS instance.

weight int

Weight associated to the ECS instance.

instanceId String

ID of the attached ECS instance.

weight Number

Weight associated to the ECS instance.

Package Details

Repository
https://github.com/pulumi/pulumi-alicloud
License
Apache-2.0
Notes

This Pulumi package is based on the alicloud Terraform Provider.