1. Packages
  2. Alicloud Provider
  3. API Docs
  4. bastionhost
  5. getUserGroups
Alibaba Cloud v3.62.1 published on Monday, Sep 16, 2024 by Pulumi

alicloud.bastionhost.getUserGroups

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.62.1 published on Monday, Sep 16, 2024 by Pulumi

    This data source provides the Bastionhost User Groups of the current Alibaba Cloud user.

    NOTE: Available in v1.132.0+.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const ids = alicloud.bastionhost.getUserGroups({
        instanceId: "bastionhost-cn-xxxx",
        ids: [
            "1",
            "2",
        ],
    });
    export const bastionhostUserGroupId1 = ids.then(ids => ids.groups?.[0]?.id);
    const nameRegex = alicloud.bastionhost.getUserGroups({
        instanceId: "bastionhost-cn-xxxx",
        nameRegex: "^my-UserGroup",
    });
    export const bastionhostUserGroupId2 = nameRegex.then(nameRegex => nameRegex.groups?.[0]?.id);
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    ids = alicloud.bastionhost.get_user_groups(instance_id="bastionhost-cn-xxxx",
        ids=[
            "1",
            "2",
        ])
    pulumi.export("bastionhostUserGroupId1", ids.groups[0].id)
    name_regex = alicloud.bastionhost.get_user_groups(instance_id="bastionhost-cn-xxxx",
        name_regex="^my-UserGroup")
    pulumi.export("bastionhostUserGroupId2", name_regex.groups[0].id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/bastionhost"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		ids, err := bastionhost.GetUserGroups(ctx, &bastionhost.GetUserGroupsArgs{
    			InstanceId: "bastionhost-cn-xxxx",
    			Ids: []string{
    				"1",
    				"2",
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("bastionhostUserGroupId1", ids.Groups[0].Id)
    		nameRegex, err := bastionhost.GetUserGroups(ctx, &bastionhost.GetUserGroupsArgs{
    			InstanceId: "bastionhost-cn-xxxx",
    			NameRegex:  pulumi.StringRef("^my-UserGroup"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("bastionhostUserGroupId2", nameRegex.Groups[0].Id)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var ids = AliCloud.BastionHost.GetUserGroups.Invoke(new()
        {
            InstanceId = "bastionhost-cn-xxxx",
            Ids = new[]
            {
                "1",
                "2",
            },
        });
    
        var nameRegex = AliCloud.BastionHost.GetUserGroups.Invoke(new()
        {
            InstanceId = "bastionhost-cn-xxxx",
            NameRegex = "^my-UserGroup",
        });
    
        return new Dictionary<string, object?>
        {
            ["bastionhostUserGroupId1"] = ids.Apply(getUserGroupsResult => getUserGroupsResult.Groups[0]?.Id),
            ["bastionhostUserGroupId2"] = nameRegex.Apply(getUserGroupsResult => getUserGroupsResult.Groups[0]?.Id),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.bastionhost.BastionhostFunctions;
    import com.pulumi.alicloud.bastionhost.inputs.GetUserGroupsArgs;
    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 ids = BastionhostFunctions.getUserGroups(GetUserGroupsArgs.builder()
                .instanceId("bastionhost-cn-xxxx")
                .ids(            
                    "1",
                    "2")
                .build());
    
            ctx.export("bastionhostUserGroupId1", ids.applyValue(getUserGroupsResult -> getUserGroupsResult.groups()[0].id()));
            final var nameRegex = BastionhostFunctions.getUserGroups(GetUserGroupsArgs.builder()
                .instanceId("bastionhost-cn-xxxx")
                .nameRegex("^my-UserGroup")
                .build());
    
            ctx.export("bastionhostUserGroupId2", nameRegex.applyValue(getUserGroupsResult -> getUserGroupsResult.groups()[0].id()));
        }
    }
    
    variables:
      ids:
        fn::invoke:
          Function: alicloud:bastionhost:getUserGroups
          Arguments:
            instanceId: bastionhost-cn-xxxx
            ids:
              - '1'
              - '2'
      nameRegex:
        fn::invoke:
          Function: alicloud:bastionhost:getUserGroups
          Arguments:
            instanceId: bastionhost-cn-xxxx
            nameRegex: ^my-UserGroup
    outputs:
      bastionhostUserGroupId1: ${ids.groups[0].id}
      bastionhostUserGroupId2: ${nameRegex.groups[0].id}
    

    Using getUserGroups

    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 getUserGroups(args: GetUserGroupsArgs, opts?: InvokeOptions): Promise<GetUserGroupsResult>
    function getUserGroupsOutput(args: GetUserGroupsOutputArgs, opts?: InvokeOptions): Output<GetUserGroupsResult>
    def get_user_groups(ids: Optional[Sequence[str]] = None,
                        instance_id: Optional[str] = None,
                        name_regex: Optional[str] = None,
                        output_file: Optional[str] = None,
                        user_group_name: Optional[str] = None,
                        opts: Optional[InvokeOptions] = None) -> GetUserGroupsResult
    def get_user_groups_output(ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                        instance_id: Optional[pulumi.Input[str]] = None,
                        name_regex: Optional[pulumi.Input[str]] = None,
                        output_file: Optional[pulumi.Input[str]] = None,
                        user_group_name: Optional[pulumi.Input[str]] = None,
                        opts: Optional[InvokeOptions] = None) -> Output[GetUserGroupsResult]
    func GetUserGroups(ctx *Context, args *GetUserGroupsArgs, opts ...InvokeOption) (*GetUserGroupsResult, error)
    func GetUserGroupsOutput(ctx *Context, args *GetUserGroupsOutputArgs, opts ...InvokeOption) GetUserGroupsResultOutput

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

    public static class GetUserGroups 
    {
        public static Task<GetUserGroupsResult> InvokeAsync(GetUserGroupsArgs args, InvokeOptions? opts = null)
        public static Output<GetUserGroupsResult> Invoke(GetUserGroupsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetUserGroupsResult> getUserGroups(GetUserGroupsArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: alicloud:bastionhost/getUserGroups:getUserGroups
      arguments:
        # arguments dictionary

    The following arguments are supported:

    InstanceId string
    Specify the New Group of the Bastion Host of Instance Id.
    Ids List<string>
    A list of User Group self IDs.
    NameRegex string
    A regex string to filter results by User Group name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    UserGroupName string
    Specify the New Group Name. Supports up to 128 Characters.
    InstanceId string
    Specify the New Group of the Bastion Host of Instance Id.
    Ids []string
    A list of User Group self IDs.
    NameRegex string
    A regex string to filter results by User Group name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    UserGroupName string
    Specify the New Group Name. Supports up to 128 Characters.
    instanceId String
    Specify the New Group of the Bastion Host of Instance Id.
    ids List<String>
    A list of User Group self IDs.
    nameRegex String
    A regex string to filter results by User Group name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    userGroupName String
    Specify the New Group Name. Supports up to 128 Characters.
    instanceId string
    Specify the New Group of the Bastion Host of Instance Id.
    ids string[]
    A list of User Group self IDs.
    nameRegex string
    A regex string to filter results by User Group name.
    outputFile string
    File name where to save data source results (after running pulumi preview).
    userGroupName string
    Specify the New Group Name. Supports up to 128 Characters.
    instance_id str
    Specify the New Group of the Bastion Host of Instance Id.
    ids Sequence[str]
    A list of User Group self IDs.
    name_regex str
    A regex string to filter results by User Group name.
    output_file str
    File name where to save data source results (after running pulumi preview).
    user_group_name str
    Specify the New Group Name. Supports up to 128 Characters.
    instanceId String
    Specify the New Group of the Bastion Host of Instance Id.
    ids List<String>
    A list of User Group self IDs.
    nameRegex String
    A regex string to filter results by User Group name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    userGroupName String
    Specify the New Group Name. Supports up to 128 Characters.

    getUserGroups Result

    The following output properties are available:

    Groups List<Pulumi.AliCloud.BastionHost.Outputs.GetUserGroupsGroup>
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids List<string>
    InstanceId string
    Names List<string>
    NameRegex string
    OutputFile string
    UserGroupName string
    Groups []GetUserGroupsGroup
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids []string
    InstanceId string
    Names []string
    NameRegex string
    OutputFile string
    UserGroupName string
    groups List<GetUserGroupsGroup>
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    instanceId String
    names List<String>
    nameRegex String
    outputFile String
    userGroupName String
    groups GetUserGroupsGroup[]
    id string
    The provider-assigned unique ID for this managed resource.
    ids string[]
    instanceId string
    names string[]
    nameRegex string
    outputFile string
    userGroupName string
    groups Sequence[GetUserGroupsGroup]
    id str
    The provider-assigned unique ID for this managed resource.
    ids Sequence[str]
    instance_id str
    names Sequence[str]
    name_regex str
    output_file str
    user_group_name str
    groups List<Property Map>
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    instanceId String
    names List<String>
    nameRegex String
    outputFile String
    userGroupName String

    Supporting Types

    GetUserGroupsGroup

    Comment string
    Specify the New Group of Remark Information. Supports up to 500 Characters.
    Id string
    The ID of the User Group.
    InstanceId string
    Specify the New Group of the Bastion Host of Instance Id.
    UserGroupId string
    The User Group ID.
    UserGroupName string
    Specify the New Group Name. Supports up to 128 Characters.
    Comment string
    Specify the New Group of Remark Information. Supports up to 500 Characters.
    Id string
    The ID of the User Group.
    InstanceId string
    Specify the New Group of the Bastion Host of Instance Id.
    UserGroupId string
    The User Group ID.
    UserGroupName string
    Specify the New Group Name. Supports up to 128 Characters.
    comment String
    Specify the New Group of Remark Information. Supports up to 500 Characters.
    id String
    The ID of the User Group.
    instanceId String
    Specify the New Group of the Bastion Host of Instance Id.
    userGroupId String
    The User Group ID.
    userGroupName String
    Specify the New Group Name. Supports up to 128 Characters.
    comment string
    Specify the New Group of Remark Information. Supports up to 500 Characters.
    id string
    The ID of the User Group.
    instanceId string
    Specify the New Group of the Bastion Host of Instance Id.
    userGroupId string
    The User Group ID.
    userGroupName string
    Specify the New Group Name. Supports up to 128 Characters.
    comment str
    Specify the New Group of Remark Information. Supports up to 500 Characters.
    id str
    The ID of the User Group.
    instance_id str
    Specify the New Group of the Bastion Host of Instance Id.
    user_group_id str
    The User Group ID.
    user_group_name str
    Specify the New Group Name. Supports up to 128 Characters.
    comment String
    Specify the New Group of Remark Information. Supports up to 500 Characters.
    id String
    The ID of the User Group.
    instanceId String
    Specify the New Group of the Bastion Host of Instance Id.
    userGroupId String
    The User Group ID.
    userGroupName String
    Specify the New Group Name. Supports up to 128 Characters.

    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.62.1 published on Monday, Sep 16, 2024 by Pulumi