Skip to content

Commit

Permalink
Support for bigquery data masking v1 api options (#7406) (#5291)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Mar 6, 2023
1 parent 038ff7f commit 69a614d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
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

0 comments on commit 69a614d

Please sign in to comment.