1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. sls
  5. getMachineGroups
Alibaba Cloud v3.86.1 published on Saturday, Sep 27, 2025 by Pulumi

alicloud.sls.getMachineGroups

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.86.1 published on Saturday, Sep 27, 2025 by Pulumi

    This data source provides Sls Machine Group available to the user.What is Machine Group

    NOTE: Available since v1.259.0.

    Example 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 projectName = config.get("projectName") || "project-for-machine-group-terraform";
    const defaultyJqrue = new alicloud.log.Project("defaultyJqrue", {
        description: "for terraform example",
        name: projectName,
    });
    const defaultMachineGroup = new alicloud.sls.MachineGroup("default", {
        groupName: "group1",
        projectName: projectName,
        machineIdentifyType: "ip",
        groupAttribute: {
            groupTopic: "example",
            externalName: "example",
        },
        machineLists: ["192.168.1.1"],
    });
    const _default = alicloud.sls.getMachineGroupsOutput({
        ids: [defaultMachineGroup.id],
        groupName: "group1",
        projectName: projectName,
    });
    export const alicloudSlsMachineGroupExampleId = _default.apply(_default => _default.groups?.[0]?.id);
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    project_name = config.get("projectName")
    if project_name is None:
        project_name = "project-for-machine-group-terraform"
    defaulty_jqrue = alicloud.log.Project("defaultyJqrue",
        description="for terraform example",
        name=project_name)
    default_machine_group = alicloud.sls.MachineGroup("default",
        group_name="group1",
        project_name=project_name,
        machine_identify_type="ip",
        group_attribute={
            "group_topic": "example",
            "external_name": "example",
        },
        machine_lists=["192.168.1.1"])
    default = alicloud.sls.get_machine_groups_output(ids=[default_machine_group.id],
        group_name="group1",
        project_name=project_name)
    pulumi.export("alicloudSlsMachineGroupExampleId", default.groups[0].id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/log"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/sls"
    	"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
    }
    projectName := "project-for-machine-group-terraform";
    if param := cfg.Get("projectName"); param != ""{
    projectName = param
    }
    _, err := log.NewProject(ctx, "defaultyJqrue", &log.ProjectArgs{
    Description: pulumi.String("for terraform example"),
    Name: pulumi.String(projectName),
    })
    if err != nil {
    return err
    }
    defaultMachineGroup, err := sls.NewMachineGroup(ctx, "default", &sls.MachineGroupArgs{
    GroupName: pulumi.String("group1"),
    ProjectName: pulumi.String(projectName),
    MachineIdentifyType: pulumi.String("ip"),
    GroupAttribute: &sls.MachineGroupGroupAttributeArgs{
    GroupTopic: pulumi.String("example"),
    ExternalName: pulumi.String("example"),
    },
    MachineLists: pulumi.StringArray{
    pulumi.String("192.168.1.1"),
    },
    })
    if err != nil {
    return err
    }
    _default := sls.GetMachineGroupsOutput(ctx, sls.GetMachineGroupsOutputArgs{
    Ids: pulumi.StringArray{
    defaultMachineGroup.ID(),
    },
    GroupName: pulumi.String("group1"),
    ProjectName: pulumi.String(projectName),
    }, nil);
    ctx.Export("alicloudSlsMachineGroupExampleId", _default.ApplyT(func(_default sls.GetMachineGroupsResult) (*string, error) {
    return &default.Groups[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") ?? "terraform-example";
        var projectName = config.Get("projectName") ?? "project-for-machine-group-terraform";
        var defaultyJqrue = new AliCloud.Log.Project("defaultyJqrue", new()
        {
            Description = "for terraform example",
            Name = projectName,
        });
    
        var defaultMachineGroup = new AliCloud.Sls.MachineGroup("default", new()
        {
            GroupName = "group1",
            ProjectName = projectName,
            MachineIdentifyType = "ip",
            GroupAttribute = new AliCloud.Sls.Inputs.MachineGroupGroupAttributeArgs
            {
                GroupTopic = "example",
                ExternalName = "example",
            },
            MachineLists = new[]
            {
                "192.168.1.1",
            },
        });
    
        var @default = AliCloud.Sls.GetMachineGroups.Invoke(new()
        {
            Ids = new[]
            {
                defaultMachineGroup.Id,
            },
            GroupName = "group1",
            ProjectName = projectName,
        });
    
        return new Dictionary<string, object?>
        {
            ["alicloudSlsMachineGroupExampleId"] = @default.Apply(@default => @default.Apply(getMachineGroupsResult => getMachineGroupsResult.Groups[0]?.Id)),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.log.Project;
    import com.pulumi.alicloud.log.ProjectArgs;
    import com.pulumi.alicloud.sls.MachineGroup;
    import com.pulumi.alicloud.sls.MachineGroupArgs;
    import com.pulumi.alicloud.sls.inputs.MachineGroupGroupAttributeArgs;
    import com.pulumi.alicloud.sls.SlsFunctions;
    import com.pulumi.alicloud.sls.inputs.GetMachineGroupsArgs;
    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");
            final var projectName = config.get("projectName").orElse("project-for-machine-group-terraform");
            var defaultyJqrue = new Project("defaultyJqrue", ProjectArgs.builder()
                .description("for terraform example")
                .name(projectName)
                .build());
    
            var defaultMachineGroup = new MachineGroup("defaultMachineGroup", MachineGroupArgs.builder()
                .groupName("group1")
                .projectName(projectName)
                .machineIdentifyType("ip")
                .groupAttribute(MachineGroupGroupAttributeArgs.builder()
                    .groupTopic("example")
                    .externalName("example")
                    .build())
                .machineLists("192.168.1.1")
                .build());
    
            final var default = SlsFunctions.getMachineGroups(GetMachineGroupsArgs.builder()
                .ids(defaultMachineGroup.id())
                .groupName("group1")
                .projectName(projectName)
                .build());
    
            ctx.export("alicloudSlsMachineGroupExampleId", default_.applyValue(_default_ -> _default_.groups()[0].id()));
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
      projectName:
        type: string
        default: project-for-machine-group-terraform
    resources:
      defaultyJqrue:
        type: alicloud:log:Project
        properties:
          description: for terraform example
          name: ${projectName}
      defaultMachineGroup:
        type: alicloud:sls:MachineGroup
        name: default
        properties:
          groupName: group1
          projectName: ${projectName}
          machineIdentifyType: ip
          groupAttribute:
            groupTopic: example
            externalName: example
          machineLists:
            - 192.168.1.1
    variables:
      default:
        fn::invoke:
          function: alicloud:sls:getMachineGroups
          arguments:
            ids:
              - ${defaultMachineGroup.id}
            groupName: group1
            projectName: ${projectName}
    outputs:
      alicloudSlsMachineGroupExampleId: ${default.groups[0].id}
    

    Using getMachineGroups

    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 getMachineGroups(args: GetMachineGroupsArgs, opts?: InvokeOptions): Promise<GetMachineGroupsResult>
    function getMachineGroupsOutput(args: GetMachineGroupsOutputArgs, opts?: InvokeOptions): Output<GetMachineGroupsResult>
    def get_machine_groups(group_name: Optional[str] = None,
                           ids: Optional[Sequence[str]] = None,
                           output_file: Optional[str] = None,
                           project_name: Optional[str] = None,
                           opts: Optional[InvokeOptions] = None) -> GetMachineGroupsResult
    def get_machine_groups_output(group_name: Optional[pulumi.Input[str]] = None,
                           ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                           output_file: Optional[pulumi.Input[str]] = None,
                           project_name: Optional[pulumi.Input[str]] = None,
                           opts: Optional[InvokeOptions] = None) -> Output[GetMachineGroupsResult]
    func GetMachineGroups(ctx *Context, args *GetMachineGroupsArgs, opts ...InvokeOption) (*GetMachineGroupsResult, error)
    func GetMachineGroupsOutput(ctx *Context, args *GetMachineGroupsOutputArgs, opts ...InvokeOption) GetMachineGroupsResultOutput

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

    public static class GetMachineGroups 
    {
        public static Task<GetMachineGroupsResult> InvokeAsync(GetMachineGroupsArgs args, InvokeOptions? opts = null)
        public static Output<GetMachineGroupsResult> Invoke(GetMachineGroupsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetMachineGroupsResult> getMachineGroups(GetMachineGroupsArgs args, InvokeOptions options)
    public static Output<GetMachineGroupsResult> getMachineGroups(GetMachineGroupsArgs args, InvokeOptions options)
    
    fn::invoke:
      function: alicloud:sls/getMachineGroups:getMachineGroups
      arguments:
        # arguments dictionary

    The following arguments are supported:

    ProjectName string
    Project name
    GroupName string
    Machine Group name
    Ids List<string>
    A list of Machine Group IDs. The value is formulated as <project_name>:<group_name>.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    ProjectName string
    Project name
    GroupName string
    Machine Group name
    Ids []string
    A list of Machine Group IDs. The value is formulated as <project_name>:<group_name>.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    projectName String
    Project name
    groupName String
    Machine Group name
    ids List<String>
    A list of Machine Group IDs. The value is formulated as <project_name>:<group_name>.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    projectName string
    Project name
    groupName string
    Machine Group name
    ids string[]
    A list of Machine Group IDs. The value is formulated as <project_name>:<group_name>.
    outputFile string
    File name where to save data source results (after running pulumi preview).
    project_name str
    Project name
    group_name str
    Machine Group name
    ids Sequence[str]
    A list of Machine Group IDs. The value is formulated as <project_name>:<group_name>.
    output_file str
    File name where to save data source results (after running pulumi preview).
    projectName String
    Project name
    groupName String
    Machine Group name
    ids List<String>
    A list of Machine Group IDs. The value is formulated as <project_name>:<group_name>.
    outputFile String
    File name where to save data source results (after running pulumi preview).

    getMachineGroups Result

    The following output properties are available:

    Groups List<Pulumi.AliCloud.Sls.Outputs.GetMachineGroupsGroup>
    A list of Machine Group Entries. Each element contains the following attributes:
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids List<string>
    A list of Machine Group IDs.
    ProjectName string
    GroupName string
    Machine Group name
    OutputFile string
    Groups []GetMachineGroupsGroup
    A list of Machine Group Entries. Each element contains the following attributes:
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids []string
    A list of Machine Group IDs.
    ProjectName string
    GroupName string
    Machine Group name
    OutputFile string
    groups List<GetMachineGroupsGroup>
    A list of Machine Group Entries. Each element contains the following attributes:
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    A list of Machine Group IDs.
    projectName String
    groupName String
    Machine Group name
    outputFile String
    groups GetMachineGroupsGroup[]
    A list of Machine Group Entries. Each element contains the following attributes:
    id string
    The provider-assigned unique ID for this managed resource.
    ids string[]
    A list of Machine Group IDs.
    projectName string
    groupName string
    Machine Group name
    outputFile string
    groups Sequence[GetMachineGroupsGroup]
    A list of Machine Group Entries. Each element contains the following attributes:
    id str
    The provider-assigned unique ID for this managed resource.
    ids Sequence[str]
    A list of Machine Group IDs.
    project_name str
    group_name str
    Machine Group name
    output_file str
    groups List<Property Map>
    A list of Machine Group Entries. Each element contains the following attributes:
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    A list of Machine Group IDs.
    projectName String
    groupName String
    Machine Group name
    outputFile String

    Supporting Types

    GetMachineGroupsGroup

    GroupName string
    Machine Group name
    Id string
    The ID of the resource supplied above.
    GroupName string
    Machine Group name
    Id string
    The ID of the resource supplied above.
    groupName String
    Machine Group name
    id String
    The ID of the resource supplied above.
    groupName string
    Machine Group name
    id string
    The ID of the resource supplied above.
    group_name str
    Machine Group name
    id str
    The ID of the resource supplied above.
    groupName String
    Machine Group name
    id String
    The ID of the resource supplied above.

    Package Details

    Repository
    Alibaba Cloud pulumi/pulumi-alicloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the alicloud Terraform Provider.
    alicloud logo
    Alibaba Cloud v3.86.1 published on Saturday, Sep 27, 2025 by Pulumi