1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. organizations
  5. getFolders
Google Cloud v8.23.0 published on Monday, Mar 24, 2025 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,
}));
Copy
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)
Copy
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
	})
}
Copy
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),
    });

});
Copy
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());

    }
}
Copy
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}
Copy

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>
Copy
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]
Copy
func GetFolders(ctx *Context, args *GetFoldersArgs, opts ...InvokeOption) (*GetFoldersResult, error)
func GetFoldersOutput(ctx *Context, args *GetFoldersOutputArgs, opts ...InvokeOption) GetFoldersResultOutput
Copy

> 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)
}
Copy
public static CompletableFuture<GetFoldersResult> getFolders(GetFoldersArgs args, InvokeOptions options)
public static Output<GetFoldersResult> getFolders(GetFoldersArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: gcp:organizations/getFolders:getFolders
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

ParentId This property is required. string
A string parent as defined in the REST API.
ParentId This property is required. string
A string parent as defined in the REST API.
parentId This property is required. String
A string parent as defined in the REST API.
parentId This property is required. string
A string parent as defined in the REST API.
parent_id This property is required. str
A string parent as defined in the REST API.
parentId This property is required. String
A string parent as defined in the REST API.

getFolders Result

The following output properties are available:

Folders List<GetFoldersFolder>
A list of folders matching the provided filter. Structure is defined below.
Id string
The provider-assigned unique ID for this managed resource.
ParentId string
Folders []GetFoldersFolder
A list of folders matching the provided filter. Structure is defined below.
Id string
The provider-assigned unique ID for this managed resource.
ParentId string
folders List<GetFoldersFolder>
A list of folders matching the provided filter. Structure is defined below.
id String
The provider-assigned unique ID for this managed resource.
parentId String
folders GetFoldersFolder[]
A list of folders matching the provided filter. Structure is defined below.
id string
The provider-assigned unique ID for this managed resource.
parentId string
folders Sequence[GetFoldersFolder]
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.
parentId String

Supporting Types

GetFoldersFolder

CreateTime This property is required. string
The timestamp of when the folder was created
DeleteTime This property is required. string
The timestamp of when the folder was requested to be deleted (if applicable)
DisplayName This property is required. string
The display name of the folder
Etag This property is required. string
Entity tag identifier of the folder
Name This property is required. string
The id of the folder
Parent This property is required. string
The parent id of the folder
State This property is required. string
The lifecycle state of the folder
UpdateTime This property is required. string
The timestamp of when the folder was last modified
CreateTime This property is required. string
The timestamp of when the folder was created
DeleteTime This property is required. string
The timestamp of when the folder was requested to be deleted (if applicable)
DisplayName This property is required. string
The display name of the folder
Etag This property is required. string
Entity tag identifier of the folder
Name This property is required. string
The id of the folder
Parent This property is required. string
The parent id of the folder
State This property is required. string
The lifecycle state of the folder
UpdateTime This property is required. string
The timestamp of when the folder was last modified
createTime This property is required. String
The timestamp of when the folder was created
deleteTime This property is required. String
The timestamp of when the folder was requested to be deleted (if applicable)
displayName This property is required. String
The display name of the folder
etag This property is required. String
Entity tag identifier of the folder
name This property is required. String
The id of the folder
parent This property is required. String
The parent id of the folder
state This property is required. String
The lifecycle state of the folder
updateTime This property is required. String
The timestamp of when the folder was last modified
createTime This property is required. string
The timestamp of when the folder was created
deleteTime This property is required. string
The timestamp of when the folder was requested to be deleted (if applicable)
displayName This property is required. string
The display name of the folder
etag This property is required. string
Entity tag identifier of the folder
name This property is required. string
The id of the folder
parent This property is required. string
The parent id of the folder
state This property is required. string
The lifecycle state of the folder
updateTime This property is required. string
The timestamp of when the folder was last modified
create_time This property is required. str
The timestamp of when the folder was created
delete_time This property is required. str
The timestamp of when the folder was requested to be deleted (if applicable)
display_name This property is required. str
The display name of the folder
etag This property is required. str
Entity tag identifier of the folder
name This property is required. str
The id of the folder
parent This property is required. str
The parent id of the folder
state This property is required. str
The lifecycle state of the folder
update_time This property is required. str
The timestamp of when the folder was last modified
createTime This property is required. String
The timestamp of when the folder was created
deleteTime This property is required. String
The timestamp of when the folder was requested to be deleted (if applicable)
displayName This property is required. String
The display name of the folder
etag This property is required. String
Entity tag identifier of the folder
name This property is required. String
The id of the folder
parent This property is required. String
The parent id of the folder
state This property is required. String
The lifecycle state of the folder
updateTime This property is required. 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-beta Terraform Provider.