blob: a6bf8e7fb58529db46460e42d402071c81f9c37c [file] [log] [blame]
---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in
# .github/CONTRIBUTING.md.
#
# ----------------------------------------------------------------------------
subcategory: "BigQuery"
description: |-
Datasets allow you to organize and control access to your tables.
---
# google\_bigquery\_dataset
Datasets allow you to organize and control access to your tables.
To get more information about Dataset, see:
* [API documentation](https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets)
* How-to Guides
* [Datasets Intro](https://cloud.google.com/bigquery/docs/datasets-intro)
~> **Warning:** You must specify the role field using the legacy format `OWNER` instead of `roles/bigquery.dataOwner`.
The API does accept both formats but it will always return the legacy format which results in Terraform
showing permanent diff on each plan and apply operation.
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=bigquery_dataset_basic&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Bigquery Dataset Basic
```hcl
resource "google_bigquery_dataset" "dataset" {
dataset_id = "example_dataset"
friendly_name = "test"
description = "This is a test description"
location = "EU"
default_table_expiration_ms = 3600000
labels = {
env = "default"
}
access {
role = "OWNER"
user_by_email = google_service_account.bqowner.email
}
access {
role = "READER"
domain = "hashicorp.com"
}
}
resource "google_service_account" "bqowner" {
account_id = "bqowner"
}
```
## Example Usage - Bigquery Dataset Cmek
```hcl
resource "google_bigquery_dataset" "dataset" {
dataset_id = "example_dataset"
friendly_name = "test"
description = "This is a test description"
location = "US"
default_table_expiration_ms = 3600000
default_encryption_configuration {
kms_key_name = google_kms_crypto_key.crypto_key.id
}
}
resource "google_kms_crypto_key" "crypto_key" {
name = "example-key"
key_ring = google_kms_key_ring.key_ring.id
}
resource "google_kms_key_ring" "key_ring" {
name = "example-keyring"
location = "us"
}
```
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=bigquery_dataset_authorized_dataset&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Bigquery Dataset Authorized Dataset
```hcl
resource "google_bigquery_dataset" "public" {
dataset_id = "public"
friendly_name = "test"
description = "This dataset is public"
location = "EU"
default_table_expiration_ms = 3600000
labels = {
env = "default"
}
access {
role = "OWNER"
user_by_email = google_service_account.bqowner.email
}
access {
role = "READER"
domain = "hashicorp.com"
}
}
resource "google_bigquery_dataset" "dataset" {
dataset_id = "private"
friendly_name = "test"
description = "This dataset is private"
location = "EU"
default_table_expiration_ms = 3600000
labels = {
env = "default"
}
access {
role = "OWNER"
user_by_email = google_service_account.bqowner.email
}
access {
role = "READER"
domain = "hashicorp.com"
}
access {
dataset {
dataset {
project_id = google_bigquery_dataset.public.project
dataset_id = google_bigquery_dataset.public.dataset_id
}
target_types = ["VIEWS"]
}
}
}
resource "google_service_account" "bqowner" {
account_id = "bqowner"
}
```
## Example Usage - Bigquery Dataset Authorized Routine
```hcl
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"
access {
role = "OWNER"
user_by_email = "my@service-account.com"
}
access {
routine {
project_id = google_bigquery_routine.public.project
dataset_id = google_bigquery_routine.public.dataset_id
routine_id = google_bigquery_routine.public.routine_id
}
}
}
```
## Example Usage - Bigquery Dataset External Reference Aws Docs
```hcl
resource "google_bigquery_dataset" "dataset" {
provider = google-beta
dataset_id = "example_dataset"
friendly_name = "test"
description = "This is a test description"
location = "aws-us-east-1"
external_dataset_reference {
external_source = "aws-glue://arn:aws:glue:us-east-1:999999999999:database/database"
connection = "projects/project/locations/aws-us-east-1/connections/connection"
}
}
```
## Argument Reference
The following arguments are supported:
* `dataset_id` -
(Required)
A unique ID for this dataset, without the project name. The ID
must contain only letters (a-z, A-Z), numbers (0-9), or
underscores (_). The maximum length is 1,024 characters.
- - -
* `max_time_travel_hours` -
(Optional)
Defines the time travel window in hours. The value can be from 48 to 168 hours (2 to 7 days).
* `access` -
(Optional)
An array of objects that define dataset access for one or more entities.
Structure is [documented below](#nested_access).
* `default_table_expiration_ms` -
(Optional)
The default lifetime of all tables in the dataset, in milliseconds.
The minimum value is 3600000 milliseconds (one hour).
Once this property is set, all newly-created tables in the dataset
will have an `expirationTime` property set to the creation time plus
the value in this property, and changing the value will only affect
new tables, not existing ones. When the `expirationTime` for a given
table is reached, that table will be deleted automatically.
If a table's `expirationTime` is modified or removed before the
table expires, or if you provide an explicit `expirationTime` when
creating a table, that value takes precedence over the default
expiration time indicated by this property.
* `default_partition_expiration_ms` -
(Optional)
The default partition expiration for all partitioned tables in
the dataset, in milliseconds.
Once this property is set, all newly-created partitioned tables in
the dataset will have an `expirationMs` property in the `timePartitioning`
settings set to this value, and changing the value will only
affect new tables, not existing ones. The storage in a partition will
have an expiration time of its partition time plus this value.
Setting this property overrides the use of `defaultTableExpirationMs`
for partitioned tables: only one of `defaultTableExpirationMs` and
`defaultPartitionExpirationMs` will be used for any new partitioned
table. If you provide an explicit `timePartitioning.expirationMs` when
creating or updating a partitioned table, that value takes precedence
over the default partition expiration time indicated by this property.
* `description` -
(Optional)
A user-friendly description of the dataset
* `external_dataset_reference` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
Information about the external metadata storage where the dataset is defined.
Structure is [documented below](#nested_external_dataset_reference).
* `friendly_name` -
(Optional)
A descriptive name for the dataset
* `labels` -
(Optional)
The labels associated with this dataset. You can use these to
organize and group your datasets.
**Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
Please refer to the field `effective_labels` for all of the labels present on the resource.
* `location` -
(Optional)
The geographic location where the dataset should reside.
See [official docs](https://cloud.google.com/bigquery/docs/dataset-locations).
There are two types of locations, regional or multi-regional. A regional
location is a specific geographic place, such as Tokyo, and a multi-regional
location is a large geographic area, such as the United States, that
contains at least two geographic places.
The default value is multi-regional location `US`.
Changing this forces a new resource to be created.
* `default_encryption_configuration` -
(Optional)
The default encryption key for all tables in the dataset. Once this property is set,
all newly-created partitioned tables in the dataset will have encryption key set to
this value, unless table creation request (or query) overrides the key.
Structure is [documented below](#nested_default_encryption_configuration).
* `is_case_insensitive` -
(Optional)
TRUE if the dataset and its table names are case-insensitive, otherwise FALSE.
By default, this is FALSE, which means the dataset and its table names are
case-sensitive. This field does not affect routine references.
* `default_collation` -
(Optional)
Defines the default collation specification of future tables created
in the dataset. If a table is created in this dataset without table-level
default collation, then the table inherits the dataset default collation,
which is applied to the string fields that do not have explicit collation
specified. A change to this field affects only tables created afterwards,
and does not alter the existing tables.
The following values are supported:
- 'und:ci': undetermined locale, case insensitive.
- '': empty string. Default to case-sensitive behavior.
* `storage_billing_model` -
(Optional)
Specifies the storage billing model for the dataset.
Set this flag value to LOGICAL to use logical bytes for storage billing,
or to PHYSICAL to use physical bytes instead.
LOGICAL is the default if this flag isn't specified.
* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
* `delete_contents_on_destroy` - (Optional) If set to `true`, delete all the tables in the
dataset when destroying the resource; otherwise,
destroying the resource will fail if tables are present.
<a name="nested_access"></a>The `access` block supports:
* `domain` -
(Optional)
A domain to grant access to. Any users signed in with the
domain specified will be granted the specified access
* `group_by_email` -
(Optional)
An email address of a Google Group to grant access to.
* `role` -
(Optional)
Describes the rights granted to the user specified by the other
member of the access object. Basic, predefined, and custom roles
are supported. Predefined roles that have equivalent basic roles
are swapped by the API to their basic counterparts. See
[official docs](https://cloud.google.com/bigquery/docs/access-control).
* `special_group` -
(Optional)
A special group to grant access to. Possible values include:
* `projectOwners`: Owners of the enclosing project.
* `projectReaders`: Readers of the enclosing project.
* `projectWriters`: Writers of the enclosing project.
* `allAuthenticatedUsers`: All authenticated BigQuery users.
* `iam_member` -
(Optional)
Some other type of member that appears in the IAM Policy but isn't a user,
group, domain, or special group. For example: `allUsers`
* `user_by_email` -
(Optional)
An email address of a user to grant access to. For example:
fred@example.com
* `view` -
(Optional)
A view from a different dataset to grant access to. Queries
executed against that view will have read access to tables in
this dataset. The role field is not required when this field is
set. If that view is updated by any user, access to the view
needs to be granted again via an update operation.
Structure is [documented below](#nested_view).
* `dataset` -
(Optional)
Grants all resources of particular types in a particular dataset read access to the current dataset.
Structure is [documented below](#nested_dataset).
* `routine` -
(Optional)
A routine from a different dataset to grant access to. Queries
executed against that routine will have read access to tables in
this dataset. The role field is not required when this field is
set. If that routine is updated by any user, access to the routine
needs to be granted again via an update operation.
Structure is [documented below](#nested_routine).
<a name="nested_view"></a>The `view` block supports:
* `dataset_id` -
(Required)
The ID of the dataset containing this table.
* `project_id` -
(Required)
The ID of the project containing this table.
* `table_id` -
(Required)
The ID of the table. The ID must contain only letters (a-z,
A-Z), numbers (0-9), or underscores (_). The maximum length
is 1,024 characters.
<a name="nested_dataset"></a>The `dataset` block supports:
* `dataset` -
(Required)
The dataset this entry applies to
Structure is [documented below](#nested_dataset).
* `target_types` -
(Required)
Which resources in the dataset this entry applies to. Currently, only views are supported,
but additional target types may be added in the future. Possible values: VIEWS
<a name="nested_dataset"></a>The `dataset` block supports:
* `dataset_id` -
(Required)
The ID of the dataset containing this table.
* `project_id` -
(Required)
The ID of the project containing this table.
<a name="nested_routine"></a>The `routine` block supports:
* `dataset_id` -
(Required)
The ID of the dataset containing this table.
* `project_id` -
(Required)
The ID of the project containing this table.
* `routine_id` -
(Required)
The ID of the routine. The ID must contain only letters (a-z,
A-Z), numbers (0-9), or underscores (_). The maximum length
is 256 characters.
<a name="nested_external_dataset_reference"></a>The `external_dataset_reference` block supports:
* `external_source` -
(Required)
External source that backs this dataset.
* `connection` -
(Required)
The connection id that is used to access the externalSource.
Format: projects/{projectId}/locations/{locationId}/connections/{connectionId}
<a name="nested_default_encryption_configuration"></a>The `default_encryption_configuration` block supports:
* `kms_key_name` -
(Required)
Describes the Cloud KMS encryption key that will be used to protect destination
BigQuery table. The BigQuery Service Account associated with your project requires
access to this encryption key.
## Attributes Reference
In addition to the arguments listed above, the following computed attributes are exported:
* `id` - an identifier for the resource with format `projects/{{project}}/datasets/{{dataset_id}}`
* `creation_time` -
The time when this dataset was created, in milliseconds since the
epoch.
* `etag` -
A hash of the resource.
* `last_modified_time` -
The date when this dataset or any of its tables was last modified, in
milliseconds since the epoch.
* `terraform_labels` -
The combination of labels configured directly on the resource
and default labels configured on the provider.
* `effective_labels` -
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.
* `self_link` - The URI of the created resource.
## Timeouts
This resource provides the following
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
- `create` - Default is 20 minutes.
- `update` - Default is 20 minutes.
- `delete` - Default is 20 minutes.
## Import
Dataset can be imported using any of these accepted formats:
* `projects/{{project}}/datasets/{{dataset_id}}`
* `{{project}}/{{dataset_id}}`
* `{{dataset_id}}`
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Dataset using one of the formats above. For example:
```tf
import {
id = "projects/{{project}}/datasets/{{dataset_id}}"
to = google_bigquery_dataset.default
}
```
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), Dataset can be imported using one of the formats above. For example:
```
$ terraform import google_bigquery_dataset.default projects/{{project}}/datasets/{{dataset_id}}
$ terraform import google_bigquery_dataset.default {{project}}/{{dataset_id}}
$ terraform import google_bigquery_dataset.default {{dataset_id}}
```
## User Project Overrides
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).