Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 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,
}));
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)
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
"github.com/pulumi/pulumi-gcp/sdk/v7/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
})
}
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),
});
});
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.projects.inputs.GetProjectArgs;
import com.pulumi.gcp.organizations.OrganizationsFunctions;
import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
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());
}
}
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}
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>
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]
func GetProject(ctx *Context, args *GetProjectArgs, opts ...InvokeOption) (*GetProjectResult, error)
func GetProjectOutput(ctx *Context, args *GetProjectOutputArgs, opts ...InvokeOption) GetProjectResultOutput
> 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)
}
public static CompletableFuture<GetProjectResult> getProject(GetProjectArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: gcp:projects/getProject:getProject
arguments:
# arguments dictionary
The following arguments are supported:
getProject Result
The following output properties are available:
- Filter string
- Id string
- The provider-assigned unique ID for this managed resource.
- Projects
List<Get
Project Project> - 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
[]Get
Project Project - 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<Get
Project Project> - 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
Get
Project Project[] - 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[Get
Project Project] - 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
- Create
Time string - Creation time in RFC3339 UTC "Zulu" format.
- Labels Dictionary<string, string>
- A set of key/value label pairs assigned on a project.
- Lifecycle
State string - The Project lifecycle state.
- Name string
- The optional user-assigned display name of the project.
- Number string
- The numeric identifier of the project.
- Parent Dictionary<string, string>
- An optional reference to a parent resource.
- Project
Id string - The project id of the project.
- Create
Time string - Creation time in RFC3339 UTC "Zulu" format.
- Labels map[string]string
- A set of key/value label pairs assigned on a project.
- Lifecycle
State string - The Project lifecycle state.
- Name string
- The optional user-assigned display name of the project.
- Number string
- The numeric identifier of the project.
- Parent map[string]string
- An optional reference to a parent resource.
- Project
Id string - The project id of the project.
- create
Time String - Creation time in RFC3339 UTC "Zulu" format.
- labels Map<String,String>
- A set of key/value label pairs assigned on a project.
- lifecycle
State String - The Project lifecycle state.
- name String
- The optional user-assigned display name of the project.
- number String
- The numeric identifier of the project.
- parent Map<String,String>
- An optional reference to a parent resource.
- project
Id String - The project id of the project.
- create
Time string - Creation time in RFC3339 UTC "Zulu" format.
- labels {[key: string]: string}
- A set of key/value label pairs assigned on a project.
- lifecycle
State string - The Project lifecycle state.
- name string
- The optional user-assigned display name of the project.
- number string
- The numeric identifier of the project.
- parent {[key: string]: string}
- An optional reference to a parent resource.
- project
Id string - The project id of the project.
- create_
time str - Creation time in RFC3339 UTC "Zulu" format.
- labels Mapping[str, str]
- A set of key/value label pairs assigned on a project.
- lifecycle_
state str - The Project lifecycle state.
- name str
- The optional user-assigned display name of the project.
- number str
- The numeric identifier of the project.
- parent Mapping[str, str]
- An optional reference to a parent resource.
- project_
id str - The project id of the project.
- create
Time String - Creation time in RFC3339 UTC "Zulu" format.
- labels Map<String>
- A set of key/value label pairs assigned on a project.
- lifecycle
State String - The Project lifecycle state.
- name String
- The optional user-assigned display name of the project.
- number String
- The numeric identifier of the project.
- parent Map<String>
- An optional reference to a parent resource.
- project
Id 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.