Table: gcp_bigquery_datasets

This table shows data for GCP BigQuery Datasets.

https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets#Dataset (opens in a new tab)

The composite primary key for this table is (project_id, id).

Relations

The following tables depend on gcp_bigquery_datasets:

Columns

NameType
_cq_iduuid
_cq_parent_iduuid
project_id (PK)utf8
accessjson
creation_timeint64
dataset_referencejson
default_collationutf8
default_encryption_configurationjson
default_partition_expiration_msint64
default_rounding_modeutf8
default_table_expiration_msint64
descriptionutf8
etagutf8
friendly_nameutf8
id (PK)utf8
is_case_insensitivebool
kindutf8
labelsjson
last_modified_timeint64
locationutf8
max_time_travel_hoursint64
satisfies_pzsbool
self_linkutf8
storage_billing_modelutf8
tagsjson

Example Queries

These SQL queries are sampled from CloudQuery policies and are compatible with PostgreSQL.

Ensure that BigQuery datasets are not anonymously or publicly accessible (Automated)

SELECT
  DISTINCT
  d.id AS resource_id,
  'Ensure that BigQuery datasets are not anonymously or publicly accessible (Automated)'
    AS title,
  d.project_id AS project_id,
  CASE
  WHEN a->>'role' = 'allUsers' OR a->>'role' = 'allAuthenticatedUsers'
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  gcp_bigquery_datasets AS d, jsonb_array_elements(d.access) AS a;

Ensure that all BigQuery Tables are encrypted with Customer-managed encryption key (CMEK) (Automated)

SELECT
  d.id AS resource_id,
  'Ensure that all BigQuery Tables are encrypted with Customer-managed encryption key (CMEK) (Automated)'
    AS title,
  d.project_id AS project_id,
  CASE
  WHEN d.default_encryption_configuration->>'kmsKeyName' = ''
  OR (d.default_encryption_configuration->>'kmsKeyName') IS NULL
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  gcp_bigquery_datasets AS d;

Ensure that a Default Customer-managed encryption key (CMEK) is specified for all BigQuery Data Sets (Automated)

SELECT
  DISTINCT
  d.id AS resource_id,
  'Ensure that a Default Customer-managed encryption key (CMEK) is specified for all BigQuery Data Sets (Automated)'
    AS title,
  d.project_id AS project_id,
  CASE
  WHEN t.encryption_configuration->>'kmsKeyName' = ''
  OR (d.default_encryption_configuration->>'kmsKeyName') IS NULL
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  gcp_bigquery_datasets AS d
  JOIN gcp_bigquery_tables AS t ON
      d.dataset_reference->>'datasetId' = t.table_reference->>'datasetId'
      AND d.dataset_reference->>'projectId' = t.table_reference->>'projectId';