google_bigquery_dataset_access

Gives dataset access for a single entity. This resource is intended to be used in cases where it is not possible to compile a full list of access blocks to include in a google_bigquery_dataset resource, to enable them to be added separately.

To get more information about DatasetAccess, see:

Example Usage - Bigquery Dataset Access Basic User

resource "google_bigquery_dataset_access" "access" {
  dataset_id    = google_bigquery_dataset.dataset.dataset_id
  role          = "OWNER"
  user_by_email = google_service_account.bqowner.email
}

resource "google_bigquery_dataset" "dataset" {
  dataset_id = "example_dataset"
}

resource "google_service_account" "bqowner" {
  account_id = "bqowner"
}

Example Usage - Bigquery Dataset Access View

resource "google_bigquery_dataset_access" "access" {
  dataset_id    = google_bigquery_dataset.private.dataset_id
  view {
    project_id = google_bigquery_table.public.project
    dataset_id = google_bigquery_dataset.public.dataset_id
    table_id   = google_bigquery_table.public.table_id
  }
}

resource "google_bigquery_dataset" "private" {
  dataset_id = "example_dataset"
}

resource "google_bigquery_dataset" "public" {
  dataset_id = "example_dataset2"
}

resource "google_bigquery_table" "public" {
  deletion_protection = false
  dataset_id = google_bigquery_dataset.public.dataset_id
  table_id   = "example_table"

  view {
    query          = "SELECT state FROM [lookerdata:cdc.project_tycho_reports]"
    use_legacy_sql = false
  }
}

Example Usage - Bigquery Dataset Access Authorized Dataset

resource "google_bigquery_dataset_access" "access" {
  dataset_id    = google_bigquery_dataset.private.dataset_id
  dataset {
    dataset{
      project_id = google_bigquery_dataset.public.project
      dataset_id = google_bigquery_dataset.public.dataset_id
    }
    target_types = ["VIEWS"]
  }
}

resource "google_bigquery_dataset" "private" {
  dataset_id = "private"
}

resource "google_bigquery_dataset" "public" {
  dataset_id = "public"
}

Example Usage - Bigquery Dataset Access Authorized Routine

resource "google_bigquery_dataset" "public" {
  dataset_id  = "public_dataset"
  description = "This dataset is public"
}

resource "google_bigquery_routine" "public" {
  dataset_id      = google_bigquery_dataset.public.dataset_id
  routine_id      = "public_routine"
  routine_type    = "TABLE_VALUED_FUNCTION"
  language        = "SQL"
  definition_body = <<-EOS
    SELECT 1 + value AS value
  EOS
  arguments {
    name          = "value"
    argument_kind = "FIXED_TYPE"
    data_type     = jsonencode({ "typeKind" = "INT64" })
  }
  return_table_type = jsonencode({ "columns" = [
    { "name" = "value", "type" = { "typeKind" = "INT64" } },
  ] })
}

resource "google_bigquery_dataset" "private" {
  dataset_id  = "private_dataset"
  description = "This dataset is private"
}

resource "google_bigquery_dataset_access" "authorized_routine" {
  dataset_id = google_bigquery_dataset.private.dataset_id
  routine {
    project_id = google_bigquery_routine.public.project
    dataset_id = google_bigquery_routine.public.dataset_id
    routine_id = google_bigquery_routine.public.routine_id
  }
}

Argument Reference

The following arguments are supported:


The view block supports:

The dataset block supports:

The dataset block supports:

The routine block supports:

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

Timeouts

This resource provides the following Timeouts configuration options:

Import

This resource does not support import.

User Project Overrides

This resource supports User Project Overrides.