1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. resourcemanager
  5. getFolders
Alibaba Cloud v3.66.0 published on Friday, Nov 15, 2024 by Pulumi

alicloud.resourcemanager.getFolders

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.66.0 published on Friday, Nov 15, 2024 by Pulumi

    This data source provides the Resource Manager Folders of the current Alibaba Cloud user.

    NOTE: Available since v1.84.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.resourcemanager.Folder("default", {folderName: name});
    const ids = alicloud.resourcemanager.getFoldersOutput({
        ids: [_default.id],
    });
    export const resourceManagerFolderId0 = ids.apply(ids => ids.folders?.[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.resourcemanager.Folder("default", folder_name=name)
    ids = alicloud.resourcemanager.get_folders_output(ids=[default.id])
    pulumi.export("resourceManagerFolderId0", ids.folders[0].id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/resourcemanager"
    	"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
    		}
    		_, err := resourcemanager.NewFolder(ctx, "default", &resourcemanager.FolderArgs{
    			FolderName: pulumi.String(name),
    		})
    		if err != nil {
    			return err
    		}
    		ids := resourcemanager.GetFoldersOutput(ctx, resourcemanager.GetFoldersOutputArgs{
    			Ids: pulumi.StringArray{
    				_default.ID(),
    			},
    		}, nil)
    		ctx.Export("resourceManagerFolderId0", ids.ApplyT(func(ids resourcemanager.GetFoldersResult) (*string, error) {
    			return &ids.Folders[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 @default = new AliCloud.ResourceManager.Folder("default", new()
        {
            FolderName = name,
        });
    
        var ids = AliCloud.ResourceManager.GetFolders.Invoke(new()
        {
            Ids = new[]
            {
                @default.Id,
            },
        });
    
        return new Dictionary<string, object?>
        {
            ["resourceManagerFolderId0"] = ids.Apply(getFoldersResult => getFoldersResult.Folders[0]?.Id),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.resourcemanager.Folder;
    import com.pulumi.alicloud.resourcemanager.FolderArgs;
    import com.pulumi.alicloud.resourcemanager.ResourcemanagerFunctions;
    import com.pulumi.alicloud.resourcemanager.inputs.GetFoldersArgs;
    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 Folder("default", FolderArgs.builder()
                .folderName(name)
                .build());
    
            final var ids = ResourcemanagerFunctions.getFolders(GetFoldersArgs.builder()
                .ids(default_.id())
                .build());
    
            ctx.export("resourceManagerFolderId0", ids.applyValue(getFoldersResult -> getFoldersResult).applyValue(ids -> ids.applyValue(getFoldersResult -> getFoldersResult.folders()[0].id())));
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      default:
        type: alicloud:resourcemanager:Folder
        properties:
          folderName: ${name}
    variables:
      ids:
        fn::invoke:
          Function: alicloud:resourcemanager:getFolders
          Arguments:
            ids:
              - ${default.id}
    outputs:
      resourceManagerFolderId0: ${ids.folders[0].id}
    

    Using getFolders

    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 getFolders(args: GetFoldersArgs, opts?: InvokeOptions): Promise<GetFoldersResult>
    function getFoldersOutput(args: GetFoldersOutputArgs, opts?: InvokeOptions): Output<GetFoldersResult>
    def get_folders(enable_details: Optional[bool] = None,
                    ids: Optional[Sequence[str]] = None,
                    name_regex: Optional[str] = None,
                    output_file: Optional[str] = None,
                    parent_folder_id: Optional[str] = None,
                    query_keyword: Optional[str] = None,
                    opts: Optional[InvokeOptions] = None) -> GetFoldersResult
    def get_folders_output(enable_details: Optional[pulumi.Input[bool]] = None,
                    ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                    name_regex: Optional[pulumi.Input[str]] = None,
                    output_file: Optional[pulumi.Input[str]] = None,
                    parent_folder_id: Optional[pulumi.Input[str]] = None,
                    query_keyword: Optional[pulumi.Input[str]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetFoldersResult]
    func GetFolders(ctx *Context, args *GetFoldersArgs, opts ...InvokeOption) (*GetFoldersResult, error)
    func GetFoldersOutput(ctx *Context, args *GetFoldersOutputArgs, opts ...InvokeOption) GetFoldersResultOutput

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

    public static class GetFolders 
    {
        public static Task<GetFoldersResult> InvokeAsync(GetFoldersArgs args, InvokeOptions? opts = null)
        public static Output<GetFoldersResult> Invoke(GetFoldersInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetFoldersResult> getFolders(GetFoldersArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: alicloud:resourcemanager/getFolders:getFolders
      arguments:
        # arguments dictionary

    The following arguments are supported:

    EnableDetails bool
    Whether to query the detailed list of resource attributes. Default value: false.
    Ids List<string>
    A list of Folders IDs.
    NameRegex string
    A regex string to filter results by Folder name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    ParentFolderId string
    The ID of the parent folder. NOTE: If parent_folder_id is not set, the information of the first-level subfolders of the Root folder is queried.
    QueryKeyword string
    The keyword used for the query, such as a folder name. Fuzzy match is supported.
    EnableDetails bool
    Whether to query the detailed list of resource attributes. Default value: false.
    Ids []string
    A list of Folders IDs.
    NameRegex string
    A regex string to filter results by Folder name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    ParentFolderId string
    The ID of the parent folder. NOTE: If parent_folder_id is not set, the information of the first-level subfolders of the Root folder is queried.
    QueryKeyword string
    The keyword used for the query, such as a folder name. Fuzzy match is supported.
    enableDetails Boolean
    Whether to query the detailed list of resource attributes. Default value: false.
    ids List<String>
    A list of Folders IDs.
    nameRegex String
    A regex string to filter results by Folder name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    parentFolderId String
    The ID of the parent folder. NOTE: If parent_folder_id is not set, the information of the first-level subfolders of the Root folder is queried.
    queryKeyword String
    The keyword used for the query, such as a folder name. Fuzzy match is supported.
    enableDetails boolean
    Whether to query the detailed list of resource attributes. Default value: false.
    ids string[]
    A list of Folders IDs.
    nameRegex string
    A regex string to filter results by Folder name.
    outputFile string
    File name where to save data source results (after running pulumi preview).
    parentFolderId string
    The ID of the parent folder. NOTE: If parent_folder_id is not set, the information of the first-level subfolders of the Root folder is queried.
    queryKeyword string
    The keyword used for the query, such as a folder name. Fuzzy match is supported.
    enable_details bool
    Whether to query the detailed list of resource attributes. Default value: false.
    ids Sequence[str]
    A list of Folders IDs.
    name_regex str
    A regex string to filter results by Folder name.
    output_file str
    File name where to save data source results (after running pulumi preview).
    parent_folder_id str
    The ID of the parent folder. NOTE: If parent_folder_id is not set, the information of the first-level subfolders of the Root folder is queried.
    query_keyword str
    The keyword used for the query, such as a folder name. Fuzzy match is supported.
    enableDetails Boolean
    Whether to query the detailed list of resource attributes. Default value: false.
    ids List<String>
    A list of Folders IDs.
    nameRegex String
    A regex string to filter results by Folder name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    parentFolderId String
    The ID of the parent folder. NOTE: If parent_folder_id is not set, the information of the first-level subfolders of the Root folder is queried.
    queryKeyword String
    The keyword used for the query, such as a folder name. Fuzzy match is supported.

    getFolders Result

    The following output properties are available:

    Folders List<Pulumi.AliCloud.ResourceManager.Outputs.GetFoldersFolder>
    A list of Folder. Each element contains the following attributes:
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids List<string>
    Names List<string>
    A list of Folder names.
    EnableDetails bool
    NameRegex string
    OutputFile string
    ParentFolderId string
    (Available since v1.114.0) The ID of the parent folder. Note: parent_folder_id takes effect only if enable_details is set to true.
    QueryKeyword string
    Folders []GetFoldersFolder
    A list of Folder. Each element contains the following attributes:
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids []string
    Names []string
    A list of Folder names.
    EnableDetails bool
    NameRegex string
    OutputFile string
    ParentFolderId string
    (Available since v1.114.0) The ID of the parent folder. Note: parent_folder_id takes effect only if enable_details is set to true.
    QueryKeyword string
    folders List<GetFoldersFolder>
    A list of Folder. Each element contains the following attributes:
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    names List<String>
    A list of Folder names.
    enableDetails Boolean
    nameRegex String
    outputFile String
    parentFolderId String
    (Available since v1.114.0) The ID of the parent folder. Note: parent_folder_id takes effect only if enable_details is set to true.
    queryKeyword String
    folders GetFoldersFolder[]
    A list of Folder. Each element contains the following attributes:
    id string
    The provider-assigned unique ID for this managed resource.
    ids string[]
    names string[]
    A list of Folder names.
    enableDetails boolean
    nameRegex string
    outputFile string
    parentFolderId string
    (Available since v1.114.0) The ID of the parent folder. Note: parent_folder_id takes effect only if enable_details is set to true.
    queryKeyword string
    folders Sequence[GetFoldersFolder]
    A list of Folder. Each element contains the following attributes:
    id str
    The provider-assigned unique ID for this managed resource.
    ids Sequence[str]
    names Sequence[str]
    A list of Folder names.
    enable_details bool
    name_regex str
    output_file str
    parent_folder_id str
    (Available since v1.114.0) The ID of the parent folder. Note: parent_folder_id takes effect only if enable_details is set to true.
    query_keyword str
    folders List<Property Map>
    A list of Folder. Each element contains the following attributes:
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    names List<String>
    A list of Folder names.
    enableDetails Boolean
    nameRegex String
    outputFile String
    parentFolderId String
    (Available since v1.114.0) The ID of the parent folder. Note: parent_folder_id takes effect only if enable_details is set to true.
    queryKeyword String

    Supporting Types

    GetFoldersFolder

    FolderId string
    The ID of the Folder.
    FolderName string
    The Name of the Folder.
    Id string
    The ID of the Resource Manager Folder.
    ParentFolderId string
    The ID of the parent folder. NOTE: If parent_folder_id is not set, the information of the first-level subfolders of the Root folder is queried.
    FolderId string
    The ID of the Folder.
    FolderName string
    The Name of the Folder.
    Id string
    The ID of the Resource Manager Folder.
    ParentFolderId string
    The ID of the parent folder. NOTE: If parent_folder_id is not set, the information of the first-level subfolders of the Root folder is queried.
    folderId String
    The ID of the Folder.
    folderName String
    The Name of the Folder.
    id String
    The ID of the Resource Manager Folder.
    parentFolderId String
    The ID of the parent folder. NOTE: If parent_folder_id is not set, the information of the first-level subfolders of the Root folder is queried.
    folderId string
    The ID of the Folder.
    folderName string
    The Name of the Folder.
    id string
    The ID of the Resource Manager Folder.
    parentFolderId string
    The ID of the parent folder. NOTE: If parent_folder_id is not set, the information of the first-level subfolders of the Root folder is queried.
    folder_id str
    The ID of the Folder.
    folder_name str
    The Name of the Folder.
    id str
    The ID of the Resource Manager Folder.
    parent_folder_id str
    The ID of the parent folder. NOTE: If parent_folder_id is not set, the information of the first-level subfolders of the Root folder is queried.
    folderId String
    The ID of the Folder.
    folderName String
    The Name of the Folder.
    id String
    The ID of the Resource Manager Folder.
    parentFolderId String
    The ID of the parent folder. NOTE: If parent_folder_id is not set, the information of the first-level subfolders of the Root folder is queried.

    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.66.0 published on Friday, Nov 15, 2024 by Pulumi