Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for bigquery data masking v1 api options #5291

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/7406.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
bigquerydatapolicy: updated api version from v1beta1 to v1 and made it possible to use additional data policies.
```
2 changes: 1 addition & 1 deletion google-beta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ var DefaultBasePaths = map[string]string{
BigQueryBasePathKey: "https://bigquery.googleapis.com/bigquery/v2/",
BigqueryAnalyticsHubBasePathKey: "https://analyticshub.googleapis.com/v1beta1/",
BigqueryConnectionBasePathKey: "https://bigqueryconnection.googleapis.com/v1/",
BigqueryDatapolicyBasePathKey: "https://bigquerydatapolicy.googleapis.com/v1beta1/",
BigqueryDatapolicyBasePathKey: "https://bigquerydatapolicy.googleapis.com/v1/",
BigqueryDataTransferBasePathKey: "https://bigquerydatatransfer.googleapis.com/v1/",
BigqueryReservationBasePathKey: "https://bigqueryreservation.googleapis.com/v1/",
BigtableBasePathKey: "https://bigtableadmin.googleapis.com/v2/",
Expand Down
4 changes: 2 additions & 2 deletions google-beta/resource_bigquery_datapolicy_data_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func ResourceBigqueryDatapolicyDataPolicy() *schema.Resource {
"predefined_expression": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validateEnum([]string{"SHA256", "ALWAYS_NULL", "DEFAULT_MASKING_VALUE"}),
Description: `The available masking rules. Learn more here: https://cloud.google.com/bigquery/docs/column-data-masking-intro#masking_options. Possible values: ["SHA256", "ALWAYS_NULL", "DEFAULT_MASKING_VALUE"]`,
ValidateFunc: validateEnum([]string{"SHA256", "ALWAYS_NULL", "DEFAULT_MASKING_VALUE", "LAST_FOUR_CHARACTERS", "FIRST_FOUR_CHARACTERS", "EMAIL_MASK", "DATE_YEAR_MASK"}),
Description: `The available masking rules. Learn more here: https://cloud.google.com/bigquery/docs/column-data-masking-intro#masking_options. Possible values: ["SHA256", "ALWAYS_NULL", "DEFAULT_MASKING_VALUE", "LAST_FOUR_CHARACTERS", "FIRST_FOUR_CHARACTERS", "EMAIL_MASK", "DATE_YEAR_MASK"]`,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func testSweepBigqueryDatapolicyDataPolicy(region string) error {
},
}

listTemplate := strings.Split("https://bigquerydatapolicy.googleapis.com/v1beta1/projects/{{project}}/locations/{{location}}/dataPolicies", "?")[0]
listTemplate := strings.Split("https://bigquerydatapolicy.googleapis.com/v1/projects/{{project}}/locations/{{location}}/dataPolicies", "?")[0]
listUrl, err := replaceVars(d, config, listTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err)
Expand Down Expand Up @@ -103,7 +103,7 @@ func testSweepBigqueryDatapolicyDataPolicy(region string) error {
continue
}

deleteTemplate := "https://bigquerydatapolicy.googleapis.com/v1beta1/projects/{{project}}/locations/{{location}}/dataPolicies/{{data_policy_id}}"
deleteTemplate := "https://bigquerydatapolicy.googleapis.com/v1/projects/{{project}}/locations/{{location}}/dataPolicies/{{data_policy_id}}"
deleteUrl, err := replaceVars(d, config, deleteTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err)
Expand Down
13 changes: 12 additions & 1 deletion google-beta/resource_bigquery_datapolicy_data_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,18 @@ resource "google_bigquery_datapolicy_data_policy" "data_policy" {
display_name = "Low security updated"
description = "A policy tag normally associated with low security items"
}


resource "google_bigquery_datapolicy_data_policy" "policy_tag_with_data_masking_policy" {
provider = google-beta
location = "us-central1"
data_policy_id = "masking_policy_test"
policy_tag = google_data_catalog_policy_tag.policy_tag_updated.name
data_policy_type = "DATA_MASKING_POLICY"
data_masking_policy {
predefined_expression = "SHA256"
}
}

resource "google_data_catalog_taxonomy" "taxonomy" {
provider = google-beta
region = "us-central1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ The following arguments are supported:
* `predefined_expression` -
(Required)
The available masking rules. Learn more here: https://cloud.google.com/bigquery/docs/column-data-masking-intro#masking_options.
Possible values are `SHA256`, `ALWAYS_NULL`, and `DEFAULT_MASKING_VALUE`.
Possible values are `SHA256`, `ALWAYS_NULL`, `DEFAULT_MASKING_VALUE`, `LAST_FOUR_CHARACTERS`, `FIRST_FOUR_CHARACTERS`, `EMAIL_MASK`, and `DATE_YEAR_MASK`.

## Attributes Reference

Expand Down