Back to source list
gcp
Official
Premium

GCP

The GCP Source plugin for CloudQuery extracts configuration from a variety of GCP APIs and loads it into any supported CloudQuery destination

Publisher

cloudquery

Latest version

v17.3.0

Type

Source

Platforms
Date Published

Price per 1M rows

Starting from $17

monthly free quota

1M rows

Set up process #


brew install cloudquery/tap/cloudquery

1. Download CLI and login

See installation options

2. Create source and destination configs

Plugin configuration

cloudquery sync gcp.yml postgresql.yml

3. Run the sync

CloudQuery sync

Overview #

The GCP Source plugin for CloudQuery extracts configuration from a variety of GCP APIs and loads it into any supported CloudQuery destination (e.g. PostgreSQL, BigQuery, Snowflake, and more).

Libraries in Use #

Authentication #

The GCP plugin authenticates using your Application Default Credentials. Available options are all the same options described here in detail:
Local Environment:
  • gcloud auth application-default login (recommended when running locally)
Google Cloud cloud-based development environment:
  • When you run on Cloud Shell or Cloud Code credentials are already available.
Google Cloud containerized environment:
  • Services such as Compute Engine, App Engine and functions supporting attaching a user-managed service account which will CloudQuery will be able to utilize.
On-premises or another cloud provider
  • The suggested way is to use Workload identity federation
  • If not available you can always use service account keys and export the location of the key via GOOGLE_APPLICATION_CREDENTIALS. Highly not recommended as long-lived keys are a security risk

Query Examples: #

Find all buckets without uniform bucket-level access #

select project_id, name from gcp_storage_buckets where uniform_bucket_level_access->>'Enabled' = 'true';


Configuration #

GCP Source Plugin Configuration Reference

Example #

This example connects a single GCP project to a Postgres destination. The (top level) source spec section is described in the Source Spec Reference.
kind: source
spec:
  # Source spec section
  name: "gcp"
  path: "cloudquery/gcp"
  registry: "cloudquery"
  version: "v17.3.0"
  tables: ["gcp_storage_buckets"]
  destinations: ["postgresql"]
  # GCP Spec
  # Learn more about the configuration options at https://cql.ink/gcp_source
  spec:
    project_ids: ["my-project"]

GCP Spec #

This is the (nested) spec used by GCP Source Plugin
  • project_ids ([]string) (default: empty. will use all projects available to the current authenticated account)
    Specify projects to connect to. If either folder_ids or project_filter is specified, these projects will be synced in addition to the projects from the folder/filter.
  • service_account_key_json (string) (default: empty)
    GCP service account key content.
    Using service accounts is not recommended, but if it is used it is better to use environment or file variable substitution.
  • folder_ids ([]string) (default: empty)
    CloudQuery will sync from all the projects in the specified folders, recursively. folder_ids must be of the format folders/<folder_id> or organizations/<organization_id>. This feature requires the resourcemanager.folders.list permission.
    By default, CloudQuery will also sync from sub-folders recursively (up to depth 100). To reduce this, set folder_recursion_depth to a lower value (or to 0 to disable recursion completely).
    Mutually exclusive with project_filter.
    If you specify * then all folders in all organizations will be synced.
  • folder_recursion_depth (integer) (default: 100)
    The maximum depth to recurse into sub-folders. 0 means no recursion (only the top-level projects in folders will be used for sync).
  • project_filter (string) (default: empty)
    A filter to determine the projects that are synced, mutually exclusive with folder_ids.
    For instance, to only sync projects where the name starts with how-, set project_filter to name:how-*.
    More examples:
    • "name:how-* OR name:test-*" matches projects starting with how- or test-
    • "NOT name:test-*" matches all projects not starting with test-
    For syntax and example queries refer to API References here and here.
  • organization_ids ([]string) (default: empty. will use all organizations available to the current authenticated account)
    Specify organizations to use when syncing organization level resources (e.g. folders or security findings).
    If organization_filter is specified, these organizations will be used in addition to the organizations from the filter.
  • organization_filter (string) (default: empty)
    A filter to determine the organizations to use when syncing organization level resources (e.g. folders or security findings).
    For instance, to use only organizations from the cloudquery.io domain, set organization_filter to domain:cloudquery.io.
    For syntax and example queries refer to API Reference here.
  • backoff_retries (integer) (default: 5)
    Maximum number of retries to make when rate limited.
  • backoff_delay (integer) (default: 30)
    Maximum delay in seconds between retries when rate limited.
  • enabled_services_only (boolean) (default: false)
    If enabled CloudQuery will skip any resources that belong to a service that has been disabled or not been enabled.
    If you use this option on a large organization (with more than 500 projects) you should also set the backoff_retries to a value greater than 0, otherwise you may hit the API rate limits.
    In >=v9.0.0 if an error is returned then CloudQuery will assume that all services are enabled and will continue to attempt to sync all specified tables rather than just ending the sync.
  • concurrency (integer) (default: 50000)
    The best effort maximum number of Go routines to use. Lower this number to reduce memory usage.
  • discovery_concurrency (integer) (default: 100)
    The number of concurrent requests that CloudQuery will make to resolve enabled services. This is only used when enabled_services_only is set to true.
  • scheduler (string) (default: round-robin)
    The scheduler to use when determining the priority of resources to sync. Supported values are dfs (depth-first search), round-robin, shuffle and shuffle-queue.
    For more information about this, see performance tuning.
  • service_account_impersonation (Service Account Impersonation spec, optional. Default: empty)
    Service Account impersonation configuration.
  • table_options (map) (default: not used)
    Table options is a premium feature. Even if some tables are free, syncing data for them (& their relations) using table options counts towards paid usage.
    Please refer to the Table Options documentation for more information.

Service Account Impersonation Spec #

  • target_principal (string) (required)
    The email address of the service account to impersonate.
  • scopes ([]string) (default: ["https://www.googleapis.com/auth/cloud-platform"])
    Scopes that the impersonated credential should have.
    See available scopes in the documentation.
  • delegates ([]string) (default: empty)
    Delegates are the service account email addresses in a delegation chain. Each service account must be granted roles/iam.serviceAccountTokenCreator on the next service account in the chain.
  • subject (string) (default: empty)
    The subject field of a JWT (sub). This field should only be set if you wish to impersonate a user. This feature is useful when using domain wide delegation.

GCP + Kubernetes (GKE) #

kind: source
spec:
  name: gcp
  path: "cloudquery/gcp"
  registry: cloudquery
  version: "v17.3.0"
  tables: ["gcp_container_clusters"]
  destinations: ["<destination>"]
---
kind: source
spec:
  name: k8s
  path: "cloudquery/k8s"
  registry: cloudquery
  version: "v7.3.0"
  tables: ["*"]
  destinations: ["<destination>"]
Kubernetes users may see the following message when running the K8s plugin on GKE Clusters:
WARNING: the gcp auth plugin is deprecated in v1.22+, unavailable in v1.26+; use gcloud instead.
As part of an initiative to remove platform specific code from Kubernetes, authentication will begin to be delegated to authentication plugins, starting in version 1.26.

What does this mean for CloudQuery users? #

CloudQuery does not use any specific resources which hinder the upgrade.

Install #

The easiest way to upgrade, is to install gke-gcloud-auth-plugin from gcloud components on Mac or Windows:
gcloud components install gke-gcloud-auth-plugin
and apt on Deb based systems:
sudo apt-get install google-cloud-sdk-gke-gcloud-auth-plugin

Verify #

Mac or Linux:
gke-gcloud-auth-plugin --version
Windows:
gke-gcloud-auth-plugin.exe --version

Switch authentication methods #

Set the flag:
export USE_GKE_GCLOUD_AUTH_PLUGIN=True
Update components:
gcloud components update
Force credential update:
gcloud container clusters get-credentials {$CLUSTER_NAME}
Now you should be able to use kubectl as normal, and you should no longer see the warning in the CloudQuery output.
For more information, read Google's press release.


Table options #

This feature enables users to override the default options for specific tables. The root of the object takes a table name, and the next level takes an API method name. The final level is the actual input object as defined by the API.
The format of the table_options object is as follows:
table_options:
  <table_name>:
    <api_method_name>:
      - <input_object>
A list of <input_object> objects should be provided. The plugin will iterate through these to make multiple API calls. This is useful for APIs like the Compute AggregatedListInstances method that only supports a single filter per call. For example:
table_options:
    gcp_compute_instances:
      aggregated_list_instances:
        - include_all_scopes: true
          filter: '(cpuPlatform = "Intel Skylake") AND (scheduling.automaticRestart = true)'
        - include_all_scopes: false
          filter: '(cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true)'
The following tables and APIs are supported:
table_options:
  gcp_compute_instances:
    aggregated_list_instances:
      - <Compute.AggregatedListInstancesRequest> # PageToken, MaxResults and Project are prohibited
The full list of supported options are documented under the Table Options section of each table in the GCP plugin tables documentation.


Licenses #

The following tools / packages are used in this plugin:
NameLicense
cel.dev/exprApache-2.0
cloud.google.com/go/accessapprovalApache-2.0
cloud.google.com/go/accesscontextmanager/apiv1/accesscontextmanagerpbApache-2.0
cloud.google.com/go/aiplatformApache-2.0
cloud.google.com/go/apigatewayApache-2.0
cloud.google.com/go/apikeysApache-2.0
cloud.google.com/go/appengineApache-2.0
cloud.google.com/go/artifactregistryApache-2.0
cloud.google.com/go/assetApache-2.0
cloud.google.com/go/authApache-2.0
cloud.google.com/go/auth/oauth2adaptApache-2.0
cloud.google.com/go/baremetalsolutionApache-2.0
cloud.google.com/go/batchApache-2.0
cloud.google.com/go/beyondcorpApache-2.0
cloud.google.com/go/bigqueryApache-2.0
cloud.google.com/go/bigtableApache-2.0
cloud.google.com/go/billingApache-2.0
cloud.google.com/go/binaryauthorizationApache-2.0
cloud.google.com/go/certificatemanagerApache-2.0
cloud.google.com/go/cloudbuildApache-2.0
cloud.google.com/go/cloudtasksApache-2.0
cloud.google.com/go/compute/apiv1Apache-2.0
cloud.google.com/go/compute/internalApache-2.0
cloud.google.com/go/compute/metadataApache-2.0
cloud.google.com/go/containerApache-2.0
cloud.google.com/go/containeranalysisApache-2.0
cloud.google.com/go/dataflowApache-2.0
cloud.google.com/go/datafusionApache-2.0
cloud.google.com/go/dataproc/v2Apache-2.0
cloud.google.com/go/deployApache-2.0
cloud.google.com/go/domainsApache-2.0
cloud.google.com/go/errorreportingApache-2.0
cloud.google.com/go/eventarcApache-2.0
cloud.google.com/go/filestoreApache-2.0
cloud.google.com/go/firestoreApache-2.0
cloud.google.com/go/functionsApache-2.0
cloud.google.com/go/iamApache-2.0
cloud.google.com/go/internalApache-2.0
cloud.google.com/go/kmsApache-2.0
cloud.google.com/go/loggingApache-2.0
cloud.google.com/go/longrunningApache-2.0
cloud.google.com/go/monitoringApache-2.0
cloud.google.com/go/networkmanagementApache-2.0
cloud.google.com/go/networkservicesApache-2.0
cloud.google.com/go/orgpolicy/apiv1/orgpolicypbApache-2.0
cloud.google.com/go/osconfigApache-2.0
cloud.google.com/go/pubsubApache-2.0
cloud.google.com/go/redisApache-2.0
cloud.google.com/go/resourcemanagerApache-2.0
cloud.google.com/go/runApache-2.0
cloud.google.com/go/schedulerApache-2.0
cloud.google.com/go/secretmanagerApache-2.0
cloud.google.com/go/securitycenterApache-2.0
cloud.google.com/go/serviceusageApache-2.0
cloud.google.com/go/storageApache-2.0
cloud.google.com/go/storagetransferApache-2.0
cloud.google.com/go/traceApache-2.0
cloud.google.com/go/translateApache-2.0
cloud.google.com/go/videoApache-2.0
cloud.google.com/go/vision/v2Apache-2.0
cloud.google.com/go/vmmigrationApache-2.0
cloud.google.com/go/vpcaccessApache-2.0
cloud.google.com/go/websecurityscannerApache-2.0
cloud.google.com/go/workflowsApache-2.0
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcpApache-2.0
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metricApache-2.0
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemappingApache-2.0
github.com/adrg/xdgMIT
github.com/apache/arrow/go/v13Apache-2.0
github.com/apache/arrow/go/v17Apache-2.0
github.com/apapsch/go-jsonmerge/v2MIT
github.com/aws/aws-sdk-go-v2Apache-2.0
github.com/aws/aws-sdk-go-v2/configApache-2.0
github.com/aws/aws-sdk-go-v2/credentialsApache-2.0
github.com/aws/aws-sdk-go-v2/feature/ec2/imdsApache-2.0
github.com/aws/aws-sdk-go-v2/internal/configsourcesApache-2.0
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2Apache-2.0
github.com/aws/aws-sdk-go-v2/internal/iniApache-2.0
github.com/aws/aws-sdk-go-v2/internal/sync/singleflightBSD-3-Clause
github.com/aws/aws-sdk-go-v2/service/internal/accept-encodingApache-2.0
github.com/aws/aws-sdk-go-v2/service/internal/presigned-urlApache-2.0
github.com/aws/aws-sdk-go-v2/service/licensemanagerApache-2.0
github.com/aws/aws-sdk-go-v2/service/marketplacemeteringApache-2.0
github.com/aws/aws-sdk-go-v2/service/ssoApache-2.0
github.com/aws/aws-sdk-go-v2/service/ssooidcApache-2.0
github.com/aws/aws-sdk-go-v2/service/stsApache-2.0
github.com/aws/smithy-goApache-2.0
github.com/aws/smithy-go/internal/sync/singleflightBSD-3-Clause
github.com/bahlo/generic-list-goBSD-3-Clause
github.com/buger/jsonparserMIT
github.com/cdfmlr/ellipsisMIT
github.com/cenkalti/backoff/v4MIT
github.com/census-instrumentation/opencensus-proto/gen-goApache-2.0
github.com/cespare/xxhash/v2MIT
github.com/cloudquery/cloudquery-api-goMPL-2.0
github.com/cloudquery/codegen/jsonschema/docsMPL-2.0
github.com/cloudquery/plugin-pb-goMPL-2.0
github.com/cloudquery/plugin-sdk/v2/internal/globMIT
github.com/cloudquery/plugin-sdk/v2/schemaMIT
github.com/cloudquery/plugin-sdk/v2/typesMPL-2.0
github.com/cloudquery/plugin-sdk/v4MPL-2.0
github.com/cloudquery/plugin-sdk/v4/globMIT
github.com/cloudquery/plugin-sdk/v4/scalarMIT
github.com/cncf/xds/goApache-2.0
github.com/davecgh/go-spew/spewISC
github.com/envoyproxy/go-control-plane/envoyApache-2.0
github.com/envoyproxy/protoc-gen-validate/validateApache-2.0
github.com/felixge/httpsnoopMIT
github.com/ghodss/yamlMIT
github.com/go-logr/logrApache-2.0
github.com/go-logr/stdrApache-2.0
github.com/goccy/go-jsonMIT
github.com/golang/groupcache/lruApache-2.0
github.com/google/flatbuffers/goApache-2.0
github.com/google/s2a-goApache-2.0
github.com/google/uuidBSD-3-Clause
github.com/googleapis/enterprise-certificate-proxy/clientApache-2.0
github.com/googleapis/gax-go/v2BSD-3-Clause
github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptorsApache-2.0
github.com/grpc-ecosystem/grpc-gateway/v2BSD-3-Clause
github.com/hashicorp/go-cleanhttpMPL-2.0
github.com/hashicorp/go-retryablehttpMPL-2.0
github.com/invopop/jsonschemaMIT
github.com/julienschmidt/httprouterBSD-3-Clause
github.com/klauspost/compressApache-2.0
github.com/klauspost/compress/internal/snaprefBSD-3-Clause
github.com/klauspost/compress/zstd/internal/xxhashMIT
github.com/mailru/easyjsonMIT
github.com/mattn/go-colorableMIT
github.com/mattn/go-isattyMIT
github.com/oapi-codegen/runtimeApache-2.0
github.com/pierrec/lz4/v4BSD-3-Clause
github.com/pmezard/go-difflib/difflibBSD-3-Clause
github.com/rs/zerologMIT
github.com/samber/loMIT
github.com/santhosh-tekuri/jsonschema/v6Apache-2.0
github.com/spf13/castMIT
github.com/spf13/cobraApache-2.0
github.com/spf13/pflagBSD-3-Clause
github.com/stretchr/testifyMIT
github.com/thoas/go-funkMIT
github.com/wk8/go-ordered-map/v2Apache-2.0
github.com/zeebo/xxh3BSD-2-Clause
go.opencensus.ioApache-2.0
go.opentelemetry.io/contrib/detectors/gcpApache-2.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpcApache-2.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttpApache-2.0
go.opentelemetry.io/otelApache-2.0
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttpApache-2.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttpApache-2.0
go.opentelemetry.io/otel/exporters/otlp/otlptraceApache-2.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttpApache-2.0
go.opentelemetry.io/otel/logApache-2.0
go.opentelemetry.io/otel/metricApache-2.0
go.opentelemetry.io/otel/sdkApache-2.0
go.opentelemetry.io/otel/sdk/logApache-2.0
go.opentelemetry.io/otel/sdk/metricApache-2.0
go.opentelemetry.io/otel/traceApache-2.0
go.opentelemetry.io/proto/otlpApache-2.0
golang.org/x/cryptoBSD-3-Clause
golang.org/x/expBSD-3-Clause
golang.org/x/netBSD-3-Clause
golang.org/x/oauth2BSD-3-Clause
golang.org/x/syncBSD-3-Clause
golang.org/x/sysBSD-3-Clause
golang.org/x/textBSD-3-Clause
golang.org/x/time/rateBSD-3-Clause
golang.org/x/xerrorsBSD-3-Clause
google.golang.org/apiBSD-3-Clause
google.golang.org/api/internal/third_party/uritemplatesBSD-3-Clause
google.golang.org/genproto/googleapisApache-2.0
google.golang.org/genproto/googleapis/apiApache-2.0
google.golang.org/genproto/googleapis/rpcApache-2.0
google.golang.org/grpcApache-2.0
google.golang.org/grpc/stats/opentelemetryApache-2.0
google.golang.org/protobufBSD-3-Clause
gopkg.in/yaml.v2Apache-2.0
gopkg.in/yaml.v3MIT


Join our mailing list

Subscribe to our newsletter to make sure you don't miss any updates.

Legal

© 2024 CloudQuery, Inc. All rights reserved.

We use tracking cookies to understand how you use the product and help us improve it. Please accept cookies to help us improve. You can always opt out later via the link in the footer.