1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. cloudasset
  5. getSearchAllResources
Google Cloud v8.23.0 published on Monday, Mar 24, 2025 by Pulumi

gcp.cloudasset.getSearchAllResources

Explore with Pulumi AI

Searches all Google Cloud resources within the specified scope, such as a project, folder, or organization. See the REST API for more details.

Example Usage

Searching For All Projects In An Org

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

const projects = gcp.cloudasset.getSearchAllResources({
    scope: "organizations/0123456789",
    assetTypes: ["cloudresourcemanager.googleapis.com/Project"],
});
Copy
import pulumi
import pulumi_gcp as gcp

projects = gcp.cloudasset.get_search_all_resources(scope="organizations/0123456789",
    asset_types=["cloudresourcemanager.googleapis.com/Project"])
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := cloudasset.LookupSearchAllResources(ctx, &cloudasset.LookupSearchAllResourcesArgs{
			Scope: "organizations/0123456789",
			AssetTypes: []string{
				"cloudresourcemanager.googleapis.com/Project",
			},
		}, 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 projects = Gcp.CloudAsset.GetSearchAllResources.Invoke(new()
    {
        Scope = "organizations/0123456789",
        AssetTypes = new[]
        {
            "cloudresourcemanager.googleapis.com/Project",
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.cloudasset.CloudassetFunctions;
import com.pulumi.gcp.cloudasset.inputs.GetSearchAllResourcesArgs;
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 projects = CloudassetFunctions.getSearchAllResources(GetSearchAllResourcesArgs.builder()
            .scope("organizations/0123456789")
            .assetTypes("cloudresourcemanager.googleapis.com/Project")
            .build());

    }
}
Copy
variables:
  projects:
    fn::invoke:
      function: gcp:cloudasset:getSearchAllResources
      arguments:
        scope: organizations/0123456789
        assetTypes:
          - cloudresourcemanager.googleapis.com/Project
Copy

Searching For All Projects With CloudBuild API Enabled

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

const cloudBuildProjects = gcp.cloudasset.getSearchAllResources({
    scope: "organizations/0123456789",
    assetTypes: ["serviceusage.googleapis.com/Service"],
    query: "displayName:cloudbuild.googleapis.com AND state:ENABLED",
});
Copy
import pulumi
import pulumi_gcp as gcp

cloud_build_projects = gcp.cloudasset.get_search_all_resources(scope="organizations/0123456789",
    asset_types=["serviceusage.googleapis.com/Service"],
    query="displayName:cloudbuild.googleapis.com AND state:ENABLED")
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := cloudasset.LookupSearchAllResources(ctx, &cloudasset.LookupSearchAllResourcesArgs{
			Scope: "organizations/0123456789",
			AssetTypes: []string{
				"serviceusage.googleapis.com/Service",
			},
			Query: pulumi.StringRef("displayName:cloudbuild.googleapis.com AND state:ENABLED"),
		}, 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 cloudBuildProjects = Gcp.CloudAsset.GetSearchAllResources.Invoke(new()
    {
        Scope = "organizations/0123456789",
        AssetTypes = new[]
        {
            "serviceusage.googleapis.com/Service",
        },
        Query = "displayName:cloudbuild.googleapis.com AND state:ENABLED",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.cloudasset.CloudassetFunctions;
import com.pulumi.gcp.cloudasset.inputs.GetSearchAllResourcesArgs;
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 cloudBuildProjects = CloudassetFunctions.getSearchAllResources(GetSearchAllResourcesArgs.builder()
            .scope("organizations/0123456789")
            .assetTypes("serviceusage.googleapis.com/Service")
            .query("displayName:cloudbuild.googleapis.com AND state:ENABLED")
            .build());

    }
}
Copy
variables:
  cloudBuildProjects:
    fn::invoke:
      function: gcp:cloudasset:getSearchAllResources
      arguments:
        scope: organizations/0123456789
        assetTypes:
          - serviceusage.googleapis.com/Service
        query: displayName:cloudbuild.googleapis.com AND state:ENABLED
Copy

Searching For All Service Accounts In A Project

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

const projectServiceAccounts = gcp.cloudasset.getSearchAllResources({
    scope: "projects/my-project-id",
    assetTypes: ["iam.googleapis.com/ServiceAccount"],
});
Copy
import pulumi
import pulumi_gcp as gcp

project_service_accounts = gcp.cloudasset.get_search_all_resources(scope="projects/my-project-id",
    asset_types=["iam.googleapis.com/ServiceAccount"])
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := cloudasset.LookupSearchAllResources(ctx, &cloudasset.LookupSearchAllResourcesArgs{
			Scope: "projects/my-project-id",
			AssetTypes: []string{
				"iam.googleapis.com/ServiceAccount",
			},
		}, 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 projectServiceAccounts = Gcp.CloudAsset.GetSearchAllResources.Invoke(new()
    {
        Scope = "projects/my-project-id",
        AssetTypes = new[]
        {
            "iam.googleapis.com/ServiceAccount",
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.cloudasset.CloudassetFunctions;
import com.pulumi.gcp.cloudasset.inputs.GetSearchAllResourcesArgs;
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 projectServiceAccounts = CloudassetFunctions.getSearchAllResources(GetSearchAllResourcesArgs.builder()
            .scope("projects/my-project-id")
            .assetTypes("iam.googleapis.com/ServiceAccount")
            .build());

    }
}
Copy
variables:
  projectServiceAccounts:
    fn::invoke:
      function: gcp:cloudasset:getSearchAllResources
      arguments:
        scope: projects/my-project-id
        assetTypes:
          - iam.googleapis.com/ServiceAccount
Copy

Using getSearchAllResources

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 getSearchAllResources(args: GetSearchAllResourcesArgs, opts?: InvokeOptions): Promise<GetSearchAllResourcesResult>
function getSearchAllResourcesOutput(args: GetSearchAllResourcesOutputArgs, opts?: InvokeOptions): Output<GetSearchAllResourcesResult>
Copy
def get_search_all_resources(asset_types: Optional[Sequence[str]] = None,
                             query: Optional[str] = None,
                             scope: Optional[str] = None,
                             opts: Optional[InvokeOptions] = None) -> GetSearchAllResourcesResult
def get_search_all_resources_output(asset_types: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                             query: Optional[pulumi.Input[str]] = None,
                             scope: Optional[pulumi.Input[str]] = None,
                             opts: Optional[InvokeOptions] = None) -> Output[GetSearchAllResourcesResult]
Copy
func LookupSearchAllResources(ctx *Context, args *LookupSearchAllResourcesArgs, opts ...InvokeOption) (*LookupSearchAllResourcesResult, error)
func LookupSearchAllResourcesOutput(ctx *Context, args *LookupSearchAllResourcesOutputArgs, opts ...InvokeOption) LookupSearchAllResourcesResultOutput
Copy

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

public static class GetSearchAllResources 
{
    public static Task<GetSearchAllResourcesResult> InvokeAsync(GetSearchAllResourcesArgs args, InvokeOptions? opts = null)
    public static Output<GetSearchAllResourcesResult> Invoke(GetSearchAllResourcesInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetSearchAllResourcesResult> getSearchAllResources(GetSearchAllResourcesArgs args, InvokeOptions options)
public static Output<GetSearchAllResourcesResult> getSearchAllResources(GetSearchAllResourcesArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: gcp:cloudasset/getSearchAllResources:getSearchAllResources
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Scope This property is required. string
A scope can be a project, a folder, or an organization. The search is limited to the resources within the scope. The allowed value must be: organization number (such as "organizations/123"), folder number (such as "folders/1234"), project number (such as "projects/12345") or project id (such as "projects/abc")
AssetTypes List<string>
A list of asset types that this request searches for. If empty, it will search all the supported asset types.
Query string
The query statement. See how to construct a query for more information. If not specified or empty, it will search all the resources within the specified scope and asset_types.
Scope This property is required. string
A scope can be a project, a folder, or an organization. The search is limited to the resources within the scope. The allowed value must be: organization number (such as "organizations/123"), folder number (such as "folders/1234"), project number (such as "projects/12345") or project id (such as "projects/abc")
AssetTypes []string
A list of asset types that this request searches for. If empty, it will search all the supported asset types.
Query string
The query statement. See how to construct a query for more information. If not specified or empty, it will search all the resources within the specified scope and asset_types.
scope This property is required. String
A scope can be a project, a folder, or an organization. The search is limited to the resources within the scope. The allowed value must be: organization number (such as "organizations/123"), folder number (such as "folders/1234"), project number (such as "projects/12345") or project id (such as "projects/abc")
assetTypes List<String>
A list of asset types that this request searches for. If empty, it will search all the supported asset types.
query String
The query statement. See how to construct a query for more information. If not specified or empty, it will search all the resources within the specified scope and asset_types.
scope This property is required. string
A scope can be a project, a folder, or an organization. The search is limited to the resources within the scope. The allowed value must be: organization number (such as "organizations/123"), folder number (such as "folders/1234"), project number (such as "projects/12345") or project id (such as "projects/abc")
assetTypes string[]
A list of asset types that this request searches for. If empty, it will search all the supported asset types.
query string
The query statement. See how to construct a query for more information. If not specified or empty, it will search all the resources within the specified scope and asset_types.
scope This property is required. str
A scope can be a project, a folder, or an organization. The search is limited to the resources within the scope. The allowed value must be: organization number (such as "organizations/123"), folder number (such as "folders/1234"), project number (such as "projects/12345") or project id (such as "projects/abc")
asset_types Sequence[str]
A list of asset types that this request searches for. If empty, it will search all the supported asset types.
query str
The query statement. See how to construct a query for more information. If not specified or empty, it will search all the resources within the specified scope and asset_types.
scope This property is required. String
A scope can be a project, a folder, or an organization. The search is limited to the resources within the scope. The allowed value must be: organization number (such as "organizations/123"), folder number (such as "folders/1234"), project number (such as "projects/12345") or project id (such as "projects/abc")
assetTypes List<String>
A list of asset types that this request searches for. If empty, it will search all the supported asset types.
query String
The query statement. See how to construct a query for more information. If not specified or empty, it will search all the resources within the specified scope and asset_types.

getSearchAllResources Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
Results List<GetSearchAllResourcesResult>
A list of search results based on provided inputs. Structure is defined below.
Scope string
AssetTypes List<string>
Query string
Id string
The provider-assigned unique ID for this managed resource.
Results []GetSearchAllResourcesResult
A list of search results based on provided inputs. Structure is defined below.
Scope string
AssetTypes []string
Query string
id String
The provider-assigned unique ID for this managed resource.
results List<GetSearchAllResourcesResult>
A list of search results based on provided inputs. Structure is defined below.
scope String
assetTypes List<String>
query String
id string
The provider-assigned unique ID for this managed resource.
results GetSearchAllResourcesResult[]
A list of search results based on provided inputs. Structure is defined below.
scope string
assetTypes string[]
query string
id str
The provider-assigned unique ID for this managed resource.
results Sequence[GetSearchAllResourcesResult]
A list of search results based on provided inputs. Structure is defined below.
scope str
asset_types Sequence[str]
query str
id String
The provider-assigned unique ID for this managed resource.
results List<Property Map>
A list of search results based on provided inputs. Structure is defined below.
scope String
assetTypes List<String>
query String

Supporting Types

GetSearchAllResourcesResult

AssetType This property is required. string
The type of this resource.
CreateTime This property is required. string
The create timestamp of this resource, at which the resource was created.
Description This property is required. string
One or more paragraphs of text description of this resource. Maximum length could be up to 1M bytes.
DisplayName This property is required. string
The display name of this resource.
Folders This property is required. List<string>
The folder(s) that this resource belongs to, in the form of folders/{FOLDER_NUMBER}. This field is available when the resource belongs to one or more folders.
KmsKeys This property is required. List<string>
The Cloud KMS CryptoKey names or CryptoKeyVersion names. This field is available only when the resource's Protobuf contains it.
Labels This property is required. Dictionary<string, string>
Labels associated with this resource.
Location This property is required. string
Location can be global, regional like us-east1, or zonal like us-west1-b.
Name This property is required. string
The full resource name of this resource.. See Resource Names for more information.
NetworkTags This property is required. List<string>
Network tags associated with this resource.
Organization This property is required. string
The organization that this resource belongs to, in the form of organizations/{ORGANIZATION_NUMBER}. This field is available when the resource belongs to an organization.
ParentAssetType This property is required. string
The type of this resource's immediate parent, if there is one.
ParentFullResourceName This property is required. string
The full resource name of this resource's parent, if it has one.
Project This property is required. string
The project that this resource belongs to, in the form of projects/{project_number}.
State This property is required. string
The state of this resource.
UpdateTime This property is required. string
The last update timestamp of this resource, at which the resource was last modified or deleted.
AssetType This property is required. string
The type of this resource.
CreateTime This property is required. string
The create timestamp of this resource, at which the resource was created.
Description This property is required. string
One or more paragraphs of text description of this resource. Maximum length could be up to 1M bytes.
DisplayName This property is required. string
The display name of this resource.
Folders This property is required. []string
The folder(s) that this resource belongs to, in the form of folders/{FOLDER_NUMBER}. This field is available when the resource belongs to one or more folders.
KmsKeys This property is required. []string
The Cloud KMS CryptoKey names or CryptoKeyVersion names. This field is available only when the resource's Protobuf contains it.
Labels This property is required. map[string]string
Labels associated with this resource.
Location This property is required. string
Location can be global, regional like us-east1, or zonal like us-west1-b.
Name This property is required. string
The full resource name of this resource.. See Resource Names for more information.
NetworkTags This property is required. []string
Network tags associated with this resource.
Organization This property is required. string
The organization that this resource belongs to, in the form of organizations/{ORGANIZATION_NUMBER}. This field is available when the resource belongs to an organization.
ParentAssetType This property is required. string
The type of this resource's immediate parent, if there is one.
ParentFullResourceName This property is required. string
The full resource name of this resource's parent, if it has one.
Project This property is required. string
The project that this resource belongs to, in the form of projects/{project_number}.
State This property is required. string
The state of this resource.
UpdateTime This property is required. string
The last update timestamp of this resource, at which the resource was last modified or deleted.
assetType This property is required. String
The type of this resource.
createTime This property is required. String
The create timestamp of this resource, at which the resource was created.
description This property is required. String
One or more paragraphs of text description of this resource. Maximum length could be up to 1M bytes.
displayName This property is required. String
The display name of this resource.
folders This property is required. List<String>
The folder(s) that this resource belongs to, in the form of folders/{FOLDER_NUMBER}. This field is available when the resource belongs to one or more folders.
kmsKeys This property is required. List<String>
The Cloud KMS CryptoKey names or CryptoKeyVersion names. This field is available only when the resource's Protobuf contains it.
labels This property is required. Map<String,String>
Labels associated with this resource.
location This property is required. String
Location can be global, regional like us-east1, or zonal like us-west1-b.
name This property is required. String
The full resource name of this resource.. See Resource Names for more information.
networkTags This property is required. List<String>
Network tags associated with this resource.
organization This property is required. String
The organization that this resource belongs to, in the form of organizations/{ORGANIZATION_NUMBER}. This field is available when the resource belongs to an organization.
parentAssetType This property is required. String
The type of this resource's immediate parent, if there is one.
parentFullResourceName This property is required. String
The full resource name of this resource's parent, if it has one.
project This property is required. String
The project that this resource belongs to, in the form of projects/{project_number}.
state This property is required. String
The state of this resource.
updateTime This property is required. String
The last update timestamp of this resource, at which the resource was last modified or deleted.
assetType This property is required. string
The type of this resource.
createTime This property is required. string
The create timestamp of this resource, at which the resource was created.
description This property is required. string
One or more paragraphs of text description of this resource. Maximum length could be up to 1M bytes.
displayName This property is required. string
The display name of this resource.
folders This property is required. string[]
The folder(s) that this resource belongs to, in the form of folders/{FOLDER_NUMBER}. This field is available when the resource belongs to one or more folders.
kmsKeys This property is required. string[]
The Cloud KMS CryptoKey names or CryptoKeyVersion names. This field is available only when the resource's Protobuf contains it.
labels This property is required. {[key: string]: string}
Labels associated with this resource.
location This property is required. string
Location can be global, regional like us-east1, or zonal like us-west1-b.
name This property is required. string
The full resource name of this resource.. See Resource Names for more information.
networkTags This property is required. string[]
Network tags associated with this resource.
organization This property is required. string
The organization that this resource belongs to, in the form of organizations/{ORGANIZATION_NUMBER}. This field is available when the resource belongs to an organization.
parentAssetType This property is required. string
The type of this resource's immediate parent, if there is one.
parentFullResourceName This property is required. string
The full resource name of this resource's parent, if it has one.
project This property is required. string
The project that this resource belongs to, in the form of projects/{project_number}.
state This property is required. string
The state of this resource.
updateTime This property is required. string
The last update timestamp of this resource, at which the resource was last modified or deleted.
asset_type This property is required. str
The type of this resource.
create_time This property is required. str
The create timestamp of this resource, at which the resource was created.
description This property is required. str
One or more paragraphs of text description of this resource. Maximum length could be up to 1M bytes.
display_name This property is required. str
The display name of this resource.
folders This property is required. Sequence[str]
The folder(s) that this resource belongs to, in the form of folders/{FOLDER_NUMBER}. This field is available when the resource belongs to one or more folders.
kms_keys This property is required. Sequence[str]
The Cloud KMS CryptoKey names or CryptoKeyVersion names. This field is available only when the resource's Protobuf contains it.
labels This property is required. Mapping[str, str]
Labels associated with this resource.
location This property is required. str
Location can be global, regional like us-east1, or zonal like us-west1-b.
name This property is required. str
The full resource name of this resource.. See Resource Names for more information.
network_tags This property is required. Sequence[str]
Network tags associated with this resource.
organization This property is required. str
The organization that this resource belongs to, in the form of organizations/{ORGANIZATION_NUMBER}. This field is available when the resource belongs to an organization.
parent_asset_type This property is required. str
The type of this resource's immediate parent, if there is one.
parent_full_resource_name This property is required. str
The full resource name of this resource's parent, if it has one.
project This property is required. str
The project that this resource belongs to, in the form of projects/{project_number}.
state This property is required. str
The state of this resource.
update_time This property is required. str
The last update timestamp of this resource, at which the resource was last modified or deleted.
assetType This property is required. String
The type of this resource.
createTime This property is required. String
The create timestamp of this resource, at which the resource was created.
description This property is required. String
One or more paragraphs of text description of this resource. Maximum length could be up to 1M bytes.
displayName This property is required. String
The display name of this resource.
folders This property is required. List<String>
The folder(s) that this resource belongs to, in the form of folders/{FOLDER_NUMBER}. This field is available when the resource belongs to one or more folders.
kmsKeys This property is required. List<String>
The Cloud KMS CryptoKey names or CryptoKeyVersion names. This field is available only when the resource's Protobuf contains it.
labels This property is required. Map<String>
Labels associated with this resource.
location This property is required. String
Location can be global, regional like us-east1, or zonal like us-west1-b.
name This property is required. String
The full resource name of this resource.. See Resource Names for more information.
networkTags This property is required. List<String>
Network tags associated with this resource.
organization This property is required. String
The organization that this resource belongs to, in the form of organizations/{ORGANIZATION_NUMBER}. This field is available when the resource belongs to an organization.
parentAssetType This property is required. String
The type of this resource's immediate parent, if there is one.
parentFullResourceName This property is required. String
The full resource name of this resource's parent, if it has one.
project This property is required. String
The project that this resource belongs to, in the form of projects/{project_number}.
state This property is required. String
The state of this resource.
updateTime This property is required. String
The last update timestamp of this resource, at which the resource was last modified or deleted.

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.