refactor access in bq module, add iam (#172)
This commit is contained in:
committed by
GitHub
parent
2ea59d2ee4
commit
cffc823f48
@@ -22,18 +22,40 @@ module "bigquery-dataset" {
|
||||
source = "./modules/bigquery-dataset"
|
||||
project_id = "my-project"
|
||||
id = "my-dataset"
|
||||
access_roles = {
|
||||
reader-group = { role = "READER", type = "group_by_email" }
|
||||
owner = { role = "OWNER", type = "user_by_email" }
|
||||
access = {
|
||||
reader-group = { role = "READER", type = "group" }
|
||||
owner = { role = "OWNER", type = "user" }
|
||||
project_owners = { role = "OWNER", type = "special_group" }
|
||||
view_1 = { role = "READER", type = "view" }
|
||||
}
|
||||
access_identities = {
|
||||
reader-group = "playground-test@ludomagno.net"
|
||||
owner = "ludo@ludomagno.net"
|
||||
reader-group = "playground-test@ludomagno.net"
|
||||
owner = "ludo@ludomagno.net"
|
||||
project_owners = "projectOwners"
|
||||
view_1 = "my-project|my-dataset|my-table"
|
||||
}
|
||||
}
|
||||
# tftest:modules=1:resources=3
|
||||
# tftest:modules=1:resources=5
|
||||
```
|
||||
|
||||
### IAM roles
|
||||
|
||||
Access configuration can also be specified via IAM instead of basic roles via the `iam` variable. When using IAM, basic roles cannot be used via the `access` family variables.
|
||||
|
||||
```hcl
|
||||
module "bigquery-dataset" {
|
||||
source = "./modules/bigquery-dataset"
|
||||
project_id = "my-project"
|
||||
id = "my-dataset"
|
||||
iam = {
|
||||
"roles/bigquery.dataOwner" = ["user:user1@example.org"]
|
||||
}
|
||||
}
|
||||
# tftest:modules=1:resources=2
|
||||
```
|
||||
|
||||
roles/bigquery.dataOwner
|
||||
|
||||
### Dataset options
|
||||
|
||||
Dataset options are set via the `options` variable. all options must be specified, but a `null` value can be set to options that need to use defaults.
|
||||
@@ -137,12 +159,12 @@ module "bigquery-dataset" {
|
||||
|---|---|:---: |:---:|:---:|
|
||||
| id | Dataset id. | <code title="">string</code> | ✓ | |
|
||||
| project_id | Id of the project where datasets will be created. | <code title="">string</code> | ✓ | |
|
||||
| *access_identities* | Map of access identities used for access roles with type different from `view`. A separate variable is needed as identities can be set to dynamic values. | <code title="map(string)">map(string)</code> | | <code title="">{}</code> |
|
||||
| *access_roles* | Map of access rules with role and identity type. Keys are arbitrary and only used to combine identities with each role. Valid types are `domain`, `group_by_email`, `special_group`, `user_by_email`, `view`. | <code title="map(object({ role = string type = string }))">map(object({...}))</code> | | <code title="">{}</code> |
|
||||
| *access_views* | Map of view data for access roles with identity type equal to `view`. A separate variable is needed as identities can be set to dynamic values. | <code title="map(object({ project_id = string dataset_id = string table_id = string }))">map(object({...}))</code> | | <code title="">{}</code> |
|
||||
| *access* | Map of access rules with role and identity type. Keys are arbitrary and must match those in the `access_identities` variable, types are `domain`, `group`, `special_group`, `user`, `view`. | <code title="map(object({ role = string type = string }))">map(object({...}))</code> | | <code title="{} validation { condition = can([ for k, v in var.access : index(["OWNER", "READER", "WRITER"], v.role) ]) error_message = "Access role must be one of 'OWNER', 'READER', 'WRITER'." } validation { condition = can([ for k, v in var.access : index(["domain", "group", "special_group", "user", "view"], v.type) ]) error_message = "Access type must be one of 'domain', 'group', 'special_group', 'user', 'view'." }">...</code> |
|
||||
| *access_identities* | Map of access identities used for basic access roles. View identities have the format 'project_id|dataset_id|table_id'. | <code title="map(string)">map(string)</code> | | <code title="">{}</code> |
|
||||
| *dataset_access* | Set access in the dataset resource instead of using separate resources. | <code title="">bool</code> | | <code title="">false</code> |
|
||||
| *encryption_key* | Self link of the KMS key that will be used to protect destination table. | <code title="">string</code> | | <code title="">null</code> |
|
||||
| *friendly_name* | Dataset friendly name. | <code title="">string</code> | | <code title="">null</code> |
|
||||
| *iam* | IAM bindings in {ROLE => [MEMBERS]} format. Mutually exclusive with the access_* variables used for basic roles. | <code title="map(list(string))">map(list(string))</code> | | <code title="">{}</code> |
|
||||
| *labels* | Dataset labels. | <code title="map(string)">map(string)</code> | | <code title="">{}</code> |
|
||||
| *location* | Dataset location. | <code title="">string</code> | | <code title="">EU</code> |
|
||||
| *options* | Dataset options. | <code title="object({ default_table_expiration_ms = number default_partition_expiration_ms = number delete_contents_on_destroy = bool })">object({...})</code> | | <code title="{ default_table_expiration_ms = null default_partition_expiration_ms = null delete_contents_on_destroy = false }">...</code> |
|
||||
|
||||
Reference in New Issue
Block a user