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

Dataset access viewer is primitive role READER not VIEWER #2092

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/3542.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
bigquery: Fixed an issue with `google_bigquery_dataset_access` failing for primitive role `roles/bigquery.dataViewer`
```
2 changes: 1 addition & 1 deletion google-beta/resource_big_query_dataset_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
var bigqueryAccessRoleToPrimitiveMap = map[string]string{
"roles/bigquery.dataOwner": "OWNER",
"roles/bigquery.dataEditor": "WRITER",
"roles/bigquery.dataViewer": "VIEWER",
"roles/bigquery.dataViewer": "READER",
}

func resourceBigQueryDatasetAccessRoleDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
Expand Down
20 changes: 16 additions & 4 deletions google-beta/resource_bigquery_dataset_access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,28 @@ func TestAccBigQueryDatasetAccess_predefinedRole(t *testing.T) {
"domain": "google.com",
}

expected2 := map[string]interface{}{
"role": "READER",
"domain": "google.com",
}

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccBigQueryDatasetAccess_predefinedRole(datasetID),
Config: testAccBigQueryDatasetAccess_predefinedRole("roles/bigquery.dataEditor", datasetID),
Check: resource.ComposeTestCheckFunc(
testAccCheckBigQueryDatasetAccessPresent(t, "google_bigquery_dataset.dataset", expected1),
),
},
{
// Update role
Config: testAccBigQueryDatasetAccess_predefinedRole("roles/bigquery.dataViewer", datasetID),
Check: resource.ComposeTestCheckFunc(
testAccCheckBigQueryDatasetAccessPresent(t, "google_bigquery_dataset.dataset", expected2),
),
},
{
// Destroy step instead of CheckDestroy so we can check the access is removed without deleting the dataset
Config: testAccBigQueryDatasetAccess_destroy(datasetID, "dataset"),
Expand Down Expand Up @@ -258,16 +270,16 @@ resource "google_bigquery_dataset" "dataset" {
`, datasetID)
}

func testAccBigQueryDatasetAccess_predefinedRole(datasetID string) string {
func testAccBigQueryDatasetAccess_predefinedRole(role, datasetID string) string {
return fmt.Sprintf(`
resource "google_bigquery_dataset_access" "access" {
dataset_id = google_bigquery_dataset.dataset.dataset_id
role = "roles/bigquery.dataEditor"
role = "%s"
domain = "google.com"
}

resource "google_bigquery_dataset" "dataset" {
dataset_id = "%s"
}
`, datasetID)
`, role, datasetID)
}