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"],
});
import pulumi
import pulumi_gcp as gcp
projects = gcp.cloudasset.get_search_all_resources(scope="organizations/0123456789",
asset_types=["cloudresourcemanager.googleapis.com/Project"])
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
})
}
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",
},
});
});
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());
}
}
variables:
projects:
fn::invoke:
function: gcp:cloudasset:getSearchAllResources
arguments:
scope: organizations/0123456789
assetTypes:
- cloudresourcemanager.googleapis.com/Project
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",
});
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")
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
})
}
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",
});
});
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());
}
}
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
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"],
});
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"])
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
})
}
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",
},
});
});
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());
}
}
variables:
projectServiceAccounts:
fn::invoke:
function: gcp:cloudasset:getSearchAllResources
arguments:
scope: projects/my-project-id
assetTypes:
- iam.googleapis.com/ServiceAccount
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>
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]
func LookupSearchAllResources(ctx *Context, args *LookupSearchAllResourcesArgs, opts ...InvokeOption) (*LookupSearchAllResourcesResult, error)
func LookupSearchAllResourcesOutput(ctx *Context, args *LookupSearchAllResourcesOutputArgs, opts ...InvokeOption) LookupSearchAllResourcesResultOutput
> 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)
}
public static CompletableFuture<GetSearchAllResourcesResult> getSearchAllResources(GetSearchAllResourcesArgs args, InvokeOptions options)
public static Output<GetSearchAllResourcesResult> getSearchAllResources(GetSearchAllResourcesArgs args, InvokeOptions options)
fn::invoke:
function: gcp:cloudasset/getSearchAllResources:getSearchAllResources
arguments:
# arguments dictionary
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")
- Asset
Types 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
andasset_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")
- Asset
Types []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
andasset_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")
- asset
Types 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
andasset_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")
- asset
Types 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
andasset_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
andasset_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")
- asset
Types 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
andasset_types
.
getSearchAllResources Result
The following output properties are available:
- Id string
- The provider-assigned unique ID for this managed resource.
- Results
List<Get
Search All Resources Result> - A list of search results based on provided inputs. Structure is defined below.
- Scope string
- Asset
Types List<string> - Query string
- Id string
- The provider-assigned unique ID for this managed resource.
- Results
[]Get
Search All Resources Result - A list of search results based on provided inputs. Structure is defined below.
- Scope string
- Asset
Types []string - Query string
- id String
- The provider-assigned unique ID for this managed resource.
- results
List<Get
Search All Resources Result> - A list of search results based on provided inputs. Structure is defined below.
- scope String
- asset
Types List<String> - query String
- id string
- The provider-assigned unique ID for this managed resource.
- results
Get
Search All Resources Result[] - A list of search results based on provided inputs. Structure is defined below.
- scope string
- asset
Types string[] - query string
- id str
- The provider-assigned unique ID for this managed resource.
- results
Sequence[Get
Search All Resources Result] - 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
- asset
Types List<String> - query String
Supporting Types
GetSearchAllResourcesResult
- Asset
Type This property is required. string - The type of this resource.
- Create
Time 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.
- Display
Name 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. - Kms
Keys 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 likeus-east1
, or zonal likeus-west1-b
. - Name
This property is required. string - The full resource name of this resource.. See Resource Names for more information.
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. - Parent
Asset Type This property is required. string - The type of this resource's immediate parent, if there is one.
- Parent
Full Resource Name 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.
- Update
Time 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. string - The type of this resource.
- Create
Time 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.
- Display
Name 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. - Kms
Keys 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 likeus-east1
, or zonal likeus-west1-b
. - Name
This property is required. string - The full resource name of this resource.. See Resource Names for more information.
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. - Parent
Asset Type This property is required. string - The type of this resource's immediate parent, if there is one.
- Parent
Full Resource Name 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.
- Update
Time 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. String - The type of this resource.
- create
Time 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.
- display
Name 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. - kms
Keys 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 likeus-east1
, or zonal likeus-west1-b
. - name
This property is required. String - The full resource name of this resource.. See Resource Names for more information.
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. - parent
Asset Type This property is required. String - The type of this resource's immediate parent, if there is one.
- parent
Full Resource Name 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.
- update
Time 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. string - The type of this resource.
- create
Time 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.
- display
Name 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. - kms
Keys 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 likeus-east1
, or zonal likeus-west1-b
. - name
This property is required. string - The full resource name of this resource.. See Resource Names for more information.
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. - parent
Asset Type This property is required. string - The type of this resource's immediate parent, if there is one.
- parent
Full Resource Name 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.
- update
Time 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 likeus-east1
, or zonal likeus-west1-b
. - name
This property is required. str - The full resource name of this resource.. See Resource Names for more information.
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.
- asset
Type This property is required. String - The type of this resource.
- create
Time 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.
- display
Name 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. - kms
Keys 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 likeus-east1
, or zonal likeus-west1-b
. - name
This property is required. String - The full resource name of this resource.. See Resource Names for more information.
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. - parent
Asset Type This property is required. String - The type of this resource's immediate parent, if there is one.
- parent
Full Resource Name 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.
- update
Time 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.