Google Cloud Classic v8.3.1 published on Wednesday, Sep 25, 2024 by Pulumi
gcp.organizations.getFolders
Explore with Pulumi AI
Retrieve information about a set of folders based on a parent ID. See the REST API for more details.
Example Usage
Searching For Folders At The Root Of An Org
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const my-org-folders = gcp.organizations.getFolders({
    parentId: `organizations/${organizationId}`,
});
const first-folder = my_org_folders.then(my_org_folders => gcp.organizations.getFolder({
    folder: my_org_folders.folders?.[0]?.name,
}));
import pulumi
import pulumi_gcp as gcp
my_org_folders = gcp.organizations.get_folders(parent_id=f"organizations/{organization_id}")
first_folder = gcp.organizations.get_folder(folder=my_org_folders.folders[0].name)
package main
import (
	"fmt"
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/organizations"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		my_org_folders, err := organizations.GetFolders(ctx, &organizations.GetFoldersArgs{
			ParentId: fmt.Sprintf("organizations/%v", organizationId),
		}, nil)
		if err != nil {
			return err
		}
		_, err = organizations.LookupFolder(ctx, &organizations.LookupFolderArgs{
			Folder: my_org_folders.Folders[0].Name,
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() => 
{
    var my_org_folders = Gcp.Organizations.GetFolders.Invoke(new()
    {
        ParentId = $"organizations/{organizationId}",
    });
    var first_folder = Gcp.Organizations.GetFolder.Invoke(new()
    {
        Folder = my_org_folders.Apply(getFoldersResult => getFoldersResult.Folders[0]?.Name),
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.organizations.OrganizationsFunctions;
import com.pulumi.gcp.organizations.inputs.GetFoldersArgs;
import com.pulumi.gcp.organizations.inputs.GetFolderArgs;
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 my-org-folders = OrganizationsFunctions.getFolders(GetFoldersArgs.builder()
            .parentId(String.format("organizations/%s", organizationId))
            .build());
        final var first-folder = OrganizationsFunctions.getFolder(GetFolderArgs.builder()
            .folder(my_org_folders.folders()[0].name())
            .build());
    }
}
variables:
  my-org-folders:
    fn::invoke:
      Function: gcp:organizations:getFolders
      Arguments:
        parentId: organizations/${organizationId}
  first-folder:
    fn::invoke:
      Function: gcp:organizations:getFolder
      Arguments:
        folder: ${["my-org-folders"].folders[0].name}
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(parent_id: Optional[str] = None,
                opts: Optional[InvokeOptions] = None) -> GetFoldersResult
def get_folders_output(parent_id: 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: gcp:organizations/getFolders:getFolders
  arguments:
    # arguments dictionaryThe following arguments are supported:
getFolders Result
The following output properties are available:
- Folders
List<Get
Folders Folder>  - A list of folders matching the provided filter. Structure is defined below.
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Parent
Id string 
- Folders
[]Get
Folders Folder  - A list of folders matching the provided filter. Structure is defined below.
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Parent
Id string 
- folders
List<Get
Folders Folder>  - A list of folders matching the provided filter. Structure is defined below.
 - id String
 - The provider-assigned unique ID for this managed resource.
 - parent
Id String 
- folders
Get
Folders Folder[]  - A list of folders matching the provided filter. Structure is defined below.
 - id string
 - The provider-assigned unique ID for this managed resource.
 - parent
Id string 
- folders
Sequence[Get
Folders Folder]  - A list of folders matching the provided filter. Structure is defined below.
 - id str
 - The provider-assigned unique ID for this managed resource.
 - parent_
id str 
- folders List<Property Map>
 - A list of folders matching the provided filter. Structure is defined below.
 - id String
 - The provider-assigned unique ID for this managed resource.
 - parent
Id String 
Supporting Types
GetFoldersFolder  
- Create
Time string - The timestamp of when the folder was created
 - Delete
Time string - The timestamp of when the folder was requested to be deleted (if applicable)
 - Display
Name string - The display name of the folder
 - Etag string
 - Entity tag identifier of the folder
 - Name string
 - The id of the folder
 - Parent string
 - The parent id of the folder
 - State string
 - The lifecycle state of the folder
 - Update
Time string - The timestamp of when the folder was last modified
 
- Create
Time string - The timestamp of when the folder was created
 - Delete
Time string - The timestamp of when the folder was requested to be deleted (if applicable)
 - Display
Name string - The display name of the folder
 - Etag string
 - Entity tag identifier of the folder
 - Name string
 - The id of the folder
 - Parent string
 - The parent id of the folder
 - State string
 - The lifecycle state of the folder
 - Update
Time string - The timestamp of when the folder was last modified
 
- create
Time String - The timestamp of when the folder was created
 - delete
Time String - The timestamp of when the folder was requested to be deleted (if applicable)
 - display
Name String - The display name of the folder
 - etag String
 - Entity tag identifier of the folder
 - name String
 - The id of the folder
 - parent String
 - The parent id of the folder
 - state String
 - The lifecycle state of the folder
 - update
Time String - The timestamp of when the folder was last modified
 
- create
Time string - The timestamp of when the folder was created
 - delete
Time string - The timestamp of when the folder was requested to be deleted (if applicable)
 - display
Name string - The display name of the folder
 - etag string
 - Entity tag identifier of the folder
 - name string
 - The id of the folder
 - parent string
 - The parent id of the folder
 - state string
 - The lifecycle state of the folder
 - update
Time string - The timestamp of when the folder was last modified
 
- create_
time str - The timestamp of when the folder was created
 - delete_
time str - The timestamp of when the folder was requested to be deleted (if applicable)
 - display_
name str - The display name of the folder
 - etag str
 - Entity tag identifier of the folder
 - name str
 - The id of the folder
 - parent str
 - The parent id of the folder
 - state str
 - The lifecycle state of the folder
 - update_
time str - The timestamp of when the folder was last modified
 
- create
Time String - The timestamp of when the folder was created
 - delete
Time String - The timestamp of when the folder was requested to be deleted (if applicable)
 - display
Name String - The display name of the folder
 - etag String
 - Entity tag identifier of the folder
 - name String
 - The id of the folder
 - parent String
 - The parent id of the folder
 - state String
 - The lifecycle state of the folder
 - update
Time String - The timestamp of when the folder was last modified
 
Package Details
- Repository
 - Google Cloud (GCP) Classic pulumi/pulumi-gcp
 - License
 - Apache-2.0
 - Notes
 - This Pulumi package is based on the 
google-betaTerraform Provider.