get Server Groups
This data source provides the Alb Server Groups of the current Alibaba Cloud user.
NOTE: Available since v1.131.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") || "terraform-example";
const _default = new alicloud.vpc.Network("default", {
vpcName: name,
cidrBlock: "192.168.0.0/16",
});
const defaultServerGroup = new alicloud.alb.ServerGroup("default", {
protocol: "HTTP",
vpcId: _default.id,
serverGroupName: name,
healthCheckConfig: {
healthCheckEnabled: false,
},
stickySessionConfig: {
stickySessionEnabled: false,
},
});
const ids = alicloud.alb.getServerGroupsOutput({
ids: [defaultServerGroup.id],
});
export const albServerGroupId0 = ids.apply(ids => ids.groups?.[0]?.id);
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform-example"
default = alicloud.vpc.Network("default",
vpc_name=name,
cidr_block="192.168.0.0/16")
default_server_group = alicloud.alb.ServerGroup("default",
protocol="HTTP",
vpc_id=default.id,
server_group_name=name,
health_check_config={
"health_check_enabled": False,
},
sticky_session_config={
"sticky_session_enabled": False,
})
ids = alicloud.alb.get_server_groups_output(ids=[default_server_group.id])
pulumi.export("albServerGroupId0", ids.groups[0].id)
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") ?? "terraform-example";
var @default = new AliCloud.Vpc.Network("default", new()
{
VpcName = name,
CidrBlock = "192.168.0.0/16",
});
var defaultServerGroup = new AliCloud.Alb.ServerGroup("default", new()
{
Protocol = "HTTP",
VpcId = @default.Id,
ServerGroupName = name,
HealthCheckConfig = new AliCloud.Alb.Inputs.ServerGroupHealthCheckConfigArgs
{
HealthCheckEnabled = false,
},
StickySessionConfig = new AliCloud.Alb.Inputs.ServerGroupStickySessionConfigArgs
{
StickySessionEnabled = false,
},
});
var ids = AliCloud.Alb.GetServerGroups.Invoke(new()
{
Ids = new[]
{
defaultServerGroup.Id,
},
});
return new Dictionary<string, object?>
{
["albServerGroupId0"] = ids.Apply(getServerGroupsResult => getServerGroupsResult.Groups[0]?.Id),
};
});
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/alb"
"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 := "terraform-example"
if param := cfg.Get("name"); param != "" {
name = param
}
_default, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
VpcName: pulumi.String(name),
CidrBlock: pulumi.String("192.168.0.0/16"),
})
if err != nil {
return err
}
defaultServerGroup, err := alb.NewServerGroup(ctx, "default", &alb.ServerGroupArgs{
Protocol: pulumi.String("HTTP"),
VpcId: _default.ID(),
ServerGroupName: pulumi.String(name),
HealthCheckConfig: &alb.ServerGroupHealthCheckConfigArgs{
HealthCheckEnabled: pulumi.Bool(false),
},
StickySessionConfig: &alb.ServerGroupStickySessionConfigArgs{
StickySessionEnabled: pulumi.Bool(false),
},
})
if err != nil {
return err
}
ids := alb.GetServerGroupsOutput(ctx, alb.GetServerGroupsOutputArgs{
Ids: pulumi.StringArray{
defaultServerGroup.ID(),
},
}, nil)
ctx.Export("albServerGroupId0", ids.ApplyT(func(ids alb.GetServerGroupsResult) (*string, error) {
return &ids.Groups[0].Id, nil
}).(pulumi.StringPtrOutput))
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.alb.ServerGroup;
import com.pulumi.alicloud.alb.ServerGroupArgs;
import com.pulumi.alicloud.alb.inputs.ServerGroupHealthCheckConfigArgs;
import com.pulumi.alicloud.alb.inputs.ServerGroupStickySessionConfigArgs;
import com.pulumi.alicloud.alb.AlbFunctions;
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("terraform-example");
var default_ = new Network("default", NetworkArgs.builder()
.vpcName(name)
.cidrBlock("192.168.0.0/16")
.build());
var defaultServerGroup = new ServerGroup("defaultServerGroup", ServerGroupArgs.builder()
.protocol("HTTP")
.vpcId(default_.id())
.serverGroupName(name)
.healthCheckConfig(ServerGroupHealthCheckConfigArgs.builder()
.healthCheckEnabled(false)
.build())
.stickySessionConfig(ServerGroupStickySessionConfigArgs.builder()
.stickySessionEnabled(false)
.build())
.build());
final var ids = AlbFunctions.getServerGroups(GetServerGroupsArgs.builder()
.ids(defaultServerGroup.id())
.build());
ctx.export("albServerGroupId0", ids.applyValue(_ids -> _ids.groups()[0].id()));
}
}
configuration:
name:
type: string
default: terraform-example
resources:
default:
type: alicloud:vpc:Network
properties:
vpcName: ${name}
cidrBlock: 192.168.0.0/16
defaultServerGroup:
type: alicloud:alb:ServerGroup
name: default
properties:
protocol: HTTP
vpcId: ${default.id}
serverGroupName: ${name}
healthCheckConfig:
healthCheckEnabled: 'false'
stickySessionConfig:
stickySessionEnabled: 'false'
variables:
ids:
fn::invoke:
function: alicloud:alb:getServerGroups
arguments:
ids:
- ${defaultServerGroup.id}
outputs:
albServerGroupId0: ${ids.groups[0].id}
Return
A collection of values returned by getServerGroups.
Parameters
A collection of arguments for invoking getServerGroups.
Return
A collection of values returned by getServerGroups.
Parameters
Whether to query the detailed list of resource attributes. Default value: false
.
A list of Server Group IDs.
A regex string to filter results by Server Group name.
File name where to save data source results (after running pulumi preview
).
The ID of the resource group.
The server group IDs.
The names of the Server Group.
The status of the Server Group. Valid values: Available
, Configuring
, Provisioning
.
A mapping of tags to assign to the resource.
The ID of the virtual private cloud (VPC).
See also
Return
A collection of values returned by getServerGroups.
Parameters
Builder for com.pulumi.alicloud.alb.kotlin.inputs.GetServerGroupsPlainArgs.