1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. projects
  5. getProject
Google Cloud v8.35.0 published on Wednesday, Jun 18, 2025 by Pulumi

gcp.projects.getProject

Explore with Pulumi AI

Retrieve information about a set of projects based on a filter. See the REST API for more details.

Example Usage

Searching For Projects About To Be Deleted In An Org

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const my_org_projects = gcp.projects.getProject({
    filter: "parent.id:012345678910 lifecycleState:DELETE_REQUESTED",
});
const deletion_candidate = my_org_projects.then(my_org_projects => gcp.organizations.getProject({
    projectId: my_org_projects.projects?.[0]?.projectId,
}));
Copy
import pulumi
import pulumi_gcp as gcp

my_org_projects = gcp.projects.get_project(filter="parent.id:012345678910 lifecycleState:DELETE_REQUESTED")
deletion_candidate = gcp.organizations.get_project(project_id=my_org_projects.projects[0].project_id)
Copy
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/organizations"
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/projects"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		my_org_projects, err := projects.GetProject(ctx, &projects.GetProjectArgs{
			Filter: "parent.id:012345678910 lifecycleState:DELETE_REQUESTED",
		}, nil)
		if err != nil {
			return err
		}
		_, err = organizations.LookupProject(ctx, &organizations.LookupProjectArgs{
			ProjectId: pulumi.StringRef(my_org_projects.Projects[0].ProjectId),
		}, 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_projects = Gcp.Projects.GetProject.Invoke(new()
    {
        Filter = "parent.id:012345678910 lifecycleState:DELETE_REQUESTED",
    });

    var deletion_candidate = Gcp.Organizations.GetProject.Invoke(new()
    {
        ProjectId = my_org_projects.Apply(getProjectResult => getProjectResult.Projects[0]?.ProjectId),
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.projects.ProjectsFunctions;
import com.pulumi.gcp.organizations.OrganizationsFunctions;
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-projects = ProjectsFunctions.getProject(GetProjectArgs.builder()
            .filter("parent.id:012345678910 lifecycleState:DELETE_REQUESTED")
            .build());

        final var deletion-candidate = OrganizationsFunctions.getProject(GetProjectArgs.builder()
            .projectId(my_org_projects.projects()[0].projectId())
            .build());

    }
}
Copy
variables:
  my-org-projects:
    fn::invoke:
      function: gcp:projects:getProject
      arguments:
        filter: parent.id:012345678910 lifecycleState:DELETE_REQUESTED
  deletion-candidate:
    fn::invoke:
      function: gcp:organizations:getProject
      arguments:
        projectId: ${["my-org-projects"].projects[0].projectId}
Copy

Using getProject

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 getProject(args: GetProjectArgs, opts?: InvokeOptions): Promise<GetProjectResult>
function getProjectOutput(args: GetProjectOutputArgs, opts?: InvokeOptions): Output<GetProjectResult>
Copy
def get_project(filter: Optional[str] = None,
                opts: Optional[InvokeOptions] = None) -> GetProjectResult
def get_project_output(filter: Optional[pulumi.Input[str]] = None,
                opts: Optional[InvokeOptions] = None) -> Output[GetProjectResult]
Copy
func GetProject(ctx *Context, args *GetProjectArgs, opts ...InvokeOption) (*GetProjectResult, error)
func GetProjectOutput(ctx *Context, args *GetProjectOutputArgs, opts ...InvokeOption) GetProjectResultOutput
Copy

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

public static class GetProject 
{
    public static Task<GetProjectResult> InvokeAsync(GetProjectArgs args, InvokeOptions? opts = null)
    public static Output<GetProjectResult> Invoke(GetProjectInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetProjectResult> getProject(GetProjectArgs args, InvokeOptions options)
public static Output<GetProjectResult> getProject(GetProjectArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: gcp:projects/getProject:getProject
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Filter This property is required. string
A string filter as defined in the REST API.
Filter This property is required. string
A string filter as defined in the REST API.
filter This property is required. String
A string filter as defined in the REST API.
filter This property is required. string
A string filter as defined in the REST API.
filter This property is required. str
A string filter as defined in the REST API.
filter This property is required. String
A string filter as defined in the REST API.

getProject Result

The following output properties are available:

Filter string
Id string
The provider-assigned unique ID for this managed resource.
Projects List<GetProjectProject>
A list of projects matching the provided filter. Structure is defined below.
Filter string
Id string
The provider-assigned unique ID for this managed resource.
Projects []GetProjectProject
A list of projects matching the provided filter. Structure is defined below.
filter String
id String
The provider-assigned unique ID for this managed resource.
projects List<GetProjectProject>
A list of projects matching the provided filter. Structure is defined below.
filter string
id string
The provider-assigned unique ID for this managed resource.
projects GetProjectProject[]
A list of projects matching the provided filter. Structure is defined below.
filter str
id str
The provider-assigned unique ID for this managed resource.
projects Sequence[GetProjectProject]
A list of projects matching the provided filter. Structure is defined below.
filter String
id String
The provider-assigned unique ID for this managed resource.
projects List<Property Map>
A list of projects matching the provided filter. Structure is defined below.

Supporting Types

GetProjectProject

CreateTime This property is required. string
Creation time in RFC3339 UTC "Zulu" format.
Labels This property is required. Dictionary<string, string>
A set of key/value label pairs assigned on a project.
LifecycleState This property is required. string
The Project lifecycle state.
Name This property is required. string
The optional user-assigned display name of the project.
Number This property is required. string
The numeric identifier of the project.
Parent This property is required. Dictionary<string, string>
An optional reference to a parent resource.
ProjectId This property is required. string
The project id of the project.
CreateTime This property is required. string
Creation time in RFC3339 UTC "Zulu" format.
Labels This property is required. map[string]string
A set of key/value label pairs assigned on a project.
LifecycleState This property is required. string
The Project lifecycle state.
Name This property is required. string
The optional user-assigned display name of the project.
Number This property is required. string
The numeric identifier of the project.
Parent This property is required. map[string]string
An optional reference to a parent resource.
ProjectId This property is required. string
The project id of the project.
createTime This property is required. String
Creation time in RFC3339 UTC "Zulu" format.
labels This property is required. Map<String,String>
A set of key/value label pairs assigned on a project.
lifecycleState This property is required. String
The Project lifecycle state.
name This property is required. String
The optional user-assigned display name of the project.
number This property is required. String
The numeric identifier of the project.
parent This property is required. Map<String,String>
An optional reference to a parent resource.
projectId This property is required. String
The project id of the project.
createTime This property is required. string
Creation time in RFC3339 UTC "Zulu" format.
labels This property is required. {[key: string]: string}
A set of key/value label pairs assigned on a project.
lifecycleState This property is required. string
The Project lifecycle state.
name This property is required. string
The optional user-assigned display name of the project.
number This property is required. string
The numeric identifier of the project.
parent This property is required. {[key: string]: string}
An optional reference to a parent resource.
projectId This property is required. string
The project id of the project.
create_time This property is required. str
Creation time in RFC3339 UTC "Zulu" format.
labels This property is required. Mapping[str, str]
A set of key/value label pairs assigned on a project.
lifecycle_state This property is required. str
The Project lifecycle state.
name This property is required. str
The optional user-assigned display name of the project.
number This property is required. str
The numeric identifier of the project.
parent This property is required. Mapping[str, str]
An optional reference to a parent resource.
project_id This property is required. str
The project id of the project.
createTime This property is required. String
Creation time in RFC3339 UTC "Zulu" format.
labels This property is required. Map<String>
A set of key/value label pairs assigned on a project.
lifecycleState This property is required. String
The Project lifecycle state.
name This property is required. String
The optional user-assigned display name of the project.
number This property is required. String
The numeric identifier of the project.
parent This property is required. Map<String>
An optional reference to a parent resource.
projectId This property is required. String
The project id of the project.

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.