1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. cloudasset
  5. getSearchAllResources
Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi

gcp.cloudasset.getSearchAllResources

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi

    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/v7/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/v7/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/v7/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)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: gcp:cloudasset/getSearchAllResources:getSearchAllResources
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Scope 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 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 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 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 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 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 string
    The type of this resource.
    CreateTime string
    The create timestamp of this resource, at which the resource was created.
    Description string
    One or more paragraphs of text description of this resource. Maximum length could be up to 1M bytes.
    DisplayName string
    The display name of this resource.
    Folders 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 List<string>
    The Cloud KMS CryptoKey names or CryptoKeyVersion names. This field is available only when the resource's Protobuf contains it.
    Labels Dictionary<string, string>
    Labels associated with this resource.
    Location string
    Location can be global, regional like us-east1, or zonal like us-west1-b.
    Name string
    The full resource name of this resource.. See Resource Names for more information.
    NetworkTags List<string>
    Network tags associated with this resource.
    Organization 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 string
    The type of this resource's immediate parent, if there is one.
    ParentFullResourceName string
    The full resource name of this resource's parent, if it has one.
    Project string
    The project that this resource belongs to, in the form of projects/{project_number}.
    State string
    The state of this resource.
    UpdateTime string
    The last update timestamp of this resource, at which the resource was last modified or deleted.
    AssetType string
    The type of this resource.
    CreateTime string
    The create timestamp of this resource, at which the resource was created.
    Description string
    One or more paragraphs of text description of this resource. Maximum length could be up to 1M bytes.
    DisplayName string
    The display name of this resource.
    Folders []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 []string
    The Cloud KMS CryptoKey names or CryptoKeyVersion names. This field is available only when the resource's Protobuf contains it.
    Labels map[string]string
    Labels associated with this resource.
    Location string
    Location can be global, regional like us-east1, or zonal like us-west1-b.
    Name string
    The full resource name of this resource.. See Resource Names for more information.
    NetworkTags []string
    Network tags associated with this resource.
    Organization 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 string
    The type of this resource's immediate parent, if there is one.
    ParentFullResourceName string
    The full resource name of this resource's parent, if it has one.
    Project string
    The project that this resource belongs to, in the form of projects/{project_number}.
    State string
    The state of this resource.
    UpdateTime string
    The last update timestamp of this resource, at which the resource was last modified or deleted.
    assetType String
    The type of this resource.
    createTime String
    The create timestamp of this resource, at which the resource was created.
    description String
    One or more paragraphs of text description of this resource. Maximum length could be up to 1M bytes.
    displayName String
    The display name of this resource.
    folders 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 List<String>
    The Cloud KMS CryptoKey names or CryptoKeyVersion names. This field is available only when the resource's Protobuf contains it.
    labels Map<String,String>
    Labels associated with this resource.
    location String
    Location can be global, regional like us-east1, or zonal like us-west1-b.
    name String
    The full resource name of this resource.. See Resource Names for more information.
    networkTags List<String>
    Network tags associated with this resource.
    organization 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 String
    The type of this resource's immediate parent, if there is one.
    parentFullResourceName String
    The full resource name of this resource's parent, if it has one.
    project String
    The project that this resource belongs to, in the form of projects/{project_number}.
    state String
    The state of this resource.
    updateTime String
    The last update timestamp of this resource, at which the resource was last modified or deleted.
    assetType string
    The type of this resource.
    createTime string
    The create timestamp of this resource, at which the resource was created.
    description string
    One or more paragraphs of text description of this resource. Maximum length could be up to 1M bytes.
    displayName string
    The display name of this resource.
    folders 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 string[]
    The Cloud KMS CryptoKey names or CryptoKeyVersion names. This field is available only when the resource's Protobuf contains it.
    labels {[key: string]: string}
    Labels associated with this resource.
    location string
    Location can be global, regional like us-east1, or zonal like us-west1-b.
    name string
    The full resource name of this resource.. See Resource Names for more information.
    networkTags string[]
    Network tags associated with this resource.
    organization 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 string
    The type of this resource's immediate parent, if there is one.
    parentFullResourceName string
    The full resource name of this resource's parent, if it has one.
    project string
    The project that this resource belongs to, in the form of projects/{project_number}.
    state string
    The state of this resource.
    updateTime string
    The last update timestamp of this resource, at which the resource was last modified or deleted.
    asset_type str
    The type of this resource.
    create_time str
    The create timestamp of this resource, at which the resource was created.
    description str
    One or more paragraphs of text description of this resource. Maximum length could be up to 1M bytes.
    display_name str
    The display name of this resource.
    folders 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 Sequence[str]
    The Cloud KMS CryptoKey names or CryptoKeyVersion names. This field is available only when the resource's Protobuf contains it.
    labels Mapping[str, str]
    Labels associated with this resource.
    location str
    Location can be global, regional like us-east1, or zonal like us-west1-b.
    name str
    The full resource name of this resource.. See Resource Names for more information.
    network_tags Sequence[str]
    Network tags associated with this resource.
    organization 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 str
    The type of this resource's immediate parent, if there is one.
    parent_full_resource_name str
    The full resource name of this resource's parent, if it has one.
    project str
    The project that this resource belongs to, in the form of projects/{project_number}.
    state str
    The state of this resource.
    update_time str
    The last update timestamp of this resource, at which the resource was last modified or deleted.
    assetType String
    The type of this resource.
    createTime String
    The create timestamp of this resource, at which the resource was created.
    description String
    One or more paragraphs of text description of this resource. Maximum length could be up to 1M bytes.
    displayName String
    The display name of this resource.
    folders 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 List<String>
    The Cloud KMS CryptoKey names or CryptoKeyVersion names. This field is available only when the resource's Protobuf contains it.
    labels Map<String>
    Labels associated with this resource.
    location String
    Location can be global, regional like us-east1, or zonal like us-west1-b.
    name String
    The full resource name of this resource.. See Resource Names for more information.
    networkTags List<String>
    Network tags associated with this resource.
    organization 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 String
    The type of this resource's immediate parent, if there is one.
    parentFullResourceName String
    The full resource name of this resource's parent, if it has one.
    project String
    The project that this resource belongs to, in the form of projects/{project_number}.
    state String
    The state of this resource.
    updateTime 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.
    gcp logo
    Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 by Pulumi