Google Cloud Classic v7.29.0 published on Wednesday, Jun 26, 2024 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/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")
- 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 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 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 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 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 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 string - The type of this resource.
- Create
Time 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.
- Display
Name 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. - Kms
Keys 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 likeus-east1
, or zonal likeus-west1-b
. - Name string
- The full resource name of this resource.. See Resource Names for more information.
- 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. - Parent
Asset stringType - The type of this resource's immediate parent, if there is one.
- Parent
Full stringResource Name - 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.
- Update
Time string - The last update timestamp of this resource, at which the resource was last modified or deleted.
- Asset
Type string - The type of this resource.
- Create
Time 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.
- Display
Name 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. - Kms
Keys []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 likeus-east1
, or zonal likeus-west1-b
. - Name string
- The full resource name of this resource.. See Resource Names for more information.
- []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. - Parent
Asset stringType - The type of this resource's immediate parent, if there is one.
- Parent
Full stringResource Name - 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.
- Update
Time string - The last update timestamp of this resource, at which the resource was last modified or deleted.
- asset
Type String - The type of this resource.
- create
Time 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.
- display
Name 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. - kms
Keys 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 likeus-east1
, or zonal likeus-west1-b
. - name String
- The full resource name of this resource.. See Resource Names for more information.
- 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. - parent
Asset StringType - The type of this resource's immediate parent, if there is one.
- parent
Full StringResource Name - 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.
- update
Time String - The last update timestamp of this resource, at which the resource was last modified or deleted.
- asset
Type string - The type of this resource.
- create
Time 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.
- display
Name 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. - kms
Keys 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 likeus-east1
, or zonal likeus-west1-b
. - name string
- The full resource name of this resource.. See Resource Names for more information.
- 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. - parent
Asset stringType - The type of this resource's immediate parent, if there is one.
- parent
Full stringResource Name - 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.
- update
Time 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 likeus-east1
, or zonal likeus-west1-b
. - name str
- The full resource name of this resource.. See Resource Names for more information.
- 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_ strtype - The type of this resource's immediate parent, if there is one.
- parent_
full_ strresource_ name - 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.
- asset
Type String - The type of this resource.
- create
Time 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.
- display
Name 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. - kms
Keys 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 likeus-east1
, or zonal likeus-west1-b
. - name String
- The full resource name of this resource.. See Resource Names for more information.
- 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. - parent
Asset StringType - The type of this resource's immediate parent, if there is one.
- parent
Full StringResource Name - 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.
- update
Time 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.