Alibaba Cloud v3.66.0 published on Friday, Nov 15, 2024 by Pulumi
alicloud.slb.getServerGroups
Explore with Pulumi AI
This data source provides the VServer groups related to a server load balancer.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "slbservergroups";
const default = alicloud.getZones({
availableDiskCategory: "cloud_efficiency",
availableResourceCreation: "VSwitch",
});
const defaultNetwork = new alicloud.vpc.Network("default", {
vpcName: name,
cidrBlock: "172.16.0.0/16",
});
const defaultSwitch = new alicloud.vpc.Switch("default", {
vpcId: defaultNetwork.id,
cidrBlock: "172.16.0.0/16",
zoneId: _default.then(_default => _default.zones?.[0]?.id),
vswitchName: name,
});
const defaultApplicationLoadBalancer = new alicloud.slb.ApplicationLoadBalancer("default", {
loadBalancerName: name,
vswitchId: defaultSwitch.id,
});
const defaultServerGroup = new alicloud.slb.ServerGroup("default", {loadBalancerId: defaultApplicationLoadBalancer.id});
const sampleDs = alicloud.slb.getServerGroupsOutput({
loadBalancerId: defaultApplicationLoadBalancer.id,
});
export const firstSlbServerGroupId = sampleDs.apply(sampleDs => sampleDs.slbServerGroups?.[0]?.id);
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "slbservergroups"
default = alicloud.get_zones(available_disk_category="cloud_efficiency",
available_resource_creation="VSwitch")
default_network = alicloud.vpc.Network("default",
vpc_name=name,
cidr_block="172.16.0.0/16")
default_switch = alicloud.vpc.Switch("default",
vpc_id=default_network.id,
cidr_block="172.16.0.0/16",
zone_id=default.zones[0].id,
vswitch_name=name)
default_application_load_balancer = alicloud.slb.ApplicationLoadBalancer("default",
load_balancer_name=name,
vswitch_id=default_switch.id)
default_server_group = alicloud.slb.ServerGroup("default", 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)
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
}
_default, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
AvailableDiskCategory: pulumi.StringRef("cloud_efficiency"),
AvailableResourceCreation: pulumi.StringRef("VSwitch"),
}, nil)
if err != nil {
return err
}
defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
VpcName: pulumi.String(name),
CidrBlock: pulumi.String("172.16.0.0/16"),
})
if err != nil {
return err
}
defaultSwitch, err := vpc.NewSwitch(ctx, "default", &vpc.SwitchArgs{
VpcId: defaultNetwork.ID(),
CidrBlock: pulumi.String("172.16.0.0/16"),
ZoneId: pulumi.String(_default.Zones[0].Id),
VswitchName: pulumi.String(name),
})
if err != nil {
return err
}
defaultApplicationLoadBalancer, err := slb.NewApplicationLoadBalancer(ctx, "default", &slb.ApplicationLoadBalancerArgs{
LoadBalancerName: pulumi.String(name),
VswitchId: defaultSwitch.ID(),
})
if err != nil {
return err
}
_, err = slb.NewServerGroup(ctx, "default", &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.StringPtrOutput))
return nil
})
}
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") ?? "slbservergroups";
var @default = AliCloud.GetZones.Invoke(new()
{
AvailableDiskCategory = "cloud_efficiency",
AvailableResourceCreation = "VSwitch",
});
var defaultNetwork = new AliCloud.Vpc.Network("default", new()
{
VpcName = name,
CidrBlock = "172.16.0.0/16",
});
var defaultSwitch = new AliCloud.Vpc.Switch("default", new()
{
VpcId = defaultNetwork.Id,
CidrBlock = "172.16.0.0/16",
ZoneId = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones[0]?.Id)),
VswitchName = name,
});
var defaultApplicationLoadBalancer = new AliCloud.Slb.ApplicationLoadBalancer("default", new()
{
LoadBalancerName = name,
VswitchId = defaultSwitch.Id,
});
var defaultServerGroup = new AliCloud.Slb.ServerGroup("default", new()
{
LoadBalancerId = defaultApplicationLoadBalancer.Id,
});
var sampleDs = AliCloud.Slb.GetServerGroups.Invoke(new()
{
LoadBalancerId = defaultApplicationLoadBalancer.Id,
});
return new Dictionary<string, object?>
{
["firstSlbServerGroupId"] = sampleDs.Apply(getServerGroupsResult => getServerGroupsResult.SlbServerGroups[0]?.Id),
};
});
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.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.slb.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 default = 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(default_.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())));
}
}
configuration:
name:
type: string
default: slbservergroups
resources:
defaultNetwork:
type: alicloud:vpc:Network
name: default
properties:
vpcName: ${name}
cidrBlock: 172.16.0.0/16
defaultSwitch:
type: alicloud:vpc:Switch
name: default
properties:
vpcId: ${defaultNetwork.id}
cidrBlock: 172.16.0.0/16
zoneId: ${default.zones[0].id}
vswitchName: ${name}
defaultApplicationLoadBalancer:
type: alicloud:slb:ApplicationLoadBalancer
name: default
properties:
loadBalancerName: ${name}
vswitchId: ${defaultSwitch.id}
defaultServerGroup:
type: alicloud:slb:ServerGroup
name: default
properties:
loadBalancerId: ${defaultApplicationLoadBalancer.id}
variables:
default:
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:
- Load
Balancer stringId - ID of the SLB.
- Ids List<string>
- A list of VServer group IDs to filter results.
- Name
Regex string - A regex string to filter results by VServer group name.
- Output
File string - File name where to save data source results (after running
pulumi preview
).
- Load
Balancer stringId - ID of the SLB.
- Ids []string
- A list of VServer group IDs to filter results.
- Name
Regex string - A regex string to filter results by VServer group name.
- Output
File string - File name where to save data source results (after running
pulumi preview
).
- load
Balancer StringId - ID of the SLB.
- ids List<String>
- A list of VServer group IDs to filter results.
- name
Regex String - A regex string to filter results by VServer group name.
- output
File String - File name where to save data source results (after running
pulumi preview
).
- load
Balancer stringId - ID of the SLB.
- ids string[]
- A list of VServer group IDs to filter results.
- name
Regex string - A regex string to filter results by VServer group name.
- output
File string - File name where to save data source results (after running
pulumi preview
).
- load_
balancer_ strid - 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 - File name where to save data source results (after running
pulumi preview
).
- load
Balancer StringId - ID of the SLB.
- ids List<String>
- A list of VServer group IDs to filter results.
- name
Regex String - A regex string to filter results by VServer group name.
- output
File String - File name where to save data source results (after running
pulumi preview
).
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.
- Load
Balancer stringId - Names List<string>
- A list of SLB VServer groups names.
- Slb
Server List<Pulumi.Groups Ali Cloud. Slb. Outputs. Get Server Groups Slb Server Group> - A list of SLB VServer groups. Each element contains the following attributes:
- Name
Regex string - Output
File string
- Id string
- The provider-assigned unique ID for this managed resource.
- Ids []string
- A list of SLB VServer groups IDs.
- Load
Balancer stringId - Names []string
- A list of SLB VServer groups names.
- Slb
Server []GetGroups Server Groups Slb Server Group - A list of SLB VServer groups. Each element contains the following attributes:
- Name
Regex string - Output
File string
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- A list of SLB VServer groups IDs.
- load
Balancer StringId - names List<String>
- A list of SLB VServer groups names.
- slb
Server List<GetGroups Server Groups Slb Server Group> - A list of SLB VServer groups. Each element contains the following attributes:
- name
Regex String - output
File String
- id string
- The provider-assigned unique ID for this managed resource.
- ids string[]
- A list of SLB VServer groups IDs.
- load
Balancer stringId - names string[]
- A list of SLB VServer groups names.
- slb
Server GetGroups Server Groups Slb Server Group[] - A list of SLB VServer groups. Each element contains the following attributes:
- name
Regex string - output
File string
- id str
- The provider-assigned unique ID for this managed resource.
- ids Sequence[str]
- A list of SLB VServer groups IDs.
- load_
balancer_ strid - names Sequence[str]
- A list of SLB VServer groups names.
- slb_
server_ Sequence[Getgroups Server Groups Slb Server Group] - 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.
- load
Balancer StringId - names List<String>
- A list of SLB VServer groups names.
- slb
Server List<Property Map>Groups - A list of SLB VServer groups. Each element contains the following attributes:
- name
Regex String - output
File String
Supporting Types
GetServerGroupsSlbServerGroup
- Id string
- VServer group ID.
- Name string
- VServer group name.
- Servers
List<Pulumi.
Ali Cloud. Slb. Inputs. Get Server Groups Slb Server Group Server> - ECS instances associated to the group. Each element contains the following attributes:
- Id string
- VServer group ID.
- Name string
- VServer group name.
- Servers
[]Get
Server Groups Slb Server Group Server - ECS instances associated to the group. Each element contains the following attributes:
- id String
- VServer group ID.
- name String
- VServer group name.
- servers
List<Get
Server Groups Slb Server Group Server> - ECS instances associated to the group. Each element contains the following attributes:
- id string
- VServer group ID.
- name string
- VServer group name.
- servers
Get
Server Groups Slb Server Group Server[] - ECS instances associated to the group. Each element contains the following attributes:
- id str
- VServer group ID.
- name str
- VServer group name.
- servers
Sequence[Get
Server Groups Slb Server Group Server] - 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
- Instance
Id string - ID of the attached ECS instance.
- Weight int
- Weight associated to the ECS instance.
- Instance
Id string - ID of the attached ECS instance.
- Weight int
- Weight associated to the ECS instance.
- instance
Id String - ID of the attached ECS instance.
- weight Integer
- Weight associated to the ECS instance.
- instance
Id 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.
- instance
Id String - ID of the attached ECS instance.
- weight Number
- Weight associated to the ECS instance.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.