From 305d3483a569a694eef5598892660ae2863a3b1c Mon Sep 17 00:00:00 2001 From: Mike Fowler Date: Fri, 21 Dec 2018 20:24:12 +0000 Subject: [PATCH] Additional bigquery locations (#2566) * Add new regional BigQuery locations. Three more regional locations are supported by BigQuery however the current validation rejects them. * Document new regional locations of BigQuery * More regions have since been added. $ make testacc TEST=./google TESTARGS='-run=TestAccBigQueryDataset' ==> Checking that code complies with gofmt requirements... TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google -v -run=TestAccBigQueryDataset -timeout 120m -ldflags="-X=github.com/terraform-providers/terraform-provider-google/version.ProviderVersion=acc" === RUN TestAccBigQueryDataset_basic === RUN TestAccBigQueryDataset_access === RUN TestAccBigQueryDataset_regionalLocation --- PASS: TestAccBigQueryDataset_basic (7.77s) --- PASS: TestAccBigQueryDataset_access (13.74s) --- PASS: TestAccBigQueryDataset_regionalLocation (93.68s) PASS ok github.com/terraform-providers/terraform-provider-google/google 93.731s --- google/resource_bigquery_dataset.go | 2 +- google/resource_bigquery_dataset_test.go | 92 +++++++++++++++++++ website/docs/r/bigquery_dataset.html.markdown | 4 +- 3 files changed, 96 insertions(+), 2 deletions(-) diff --git a/google/resource_bigquery_dataset.go b/google/resource_bigquery_dataset.go index e17f0dee..7b1da355 100644 --- a/google/resource_bigquery_dataset.go +++ b/google/resource_bigquery_dataset.go @@ -72,7 +72,7 @@ func resourceBigQueryDataset() *schema.Resource { Optional: true, ForceNew: true, Default: "US", - ValidateFunc: validation.StringInSlice([]string{"US", "EU", "asia-northeast1", "europe-west2", "australia-southeast1"}, false), + ValidateFunc: validation.StringInSlice([]string{"US", "EU", "asia-east1", "asia-northeast1", "asia-southeast1", "australia-southeast1", "europe-north1", "europe-west2", "us-east4"}, false), }, // defaultPartitionExpirationMs: [Optional] The default partition diff --git a/google/resource_bigquery_dataset_test.go b/google/resource_bigquery_dataset_test.go index 2aa02354..9b162d15 100644 --- a/google/resource_bigquery_dataset_test.go +++ b/google/resource_bigquery_dataset_test.go @@ -87,6 +87,82 @@ func TestAccBigQueryDataset_access(t *testing.T) { }) } +func TestAccBigQueryDataset_regionalLocation(t *testing.T) { + t.Parallel() + + datasetID1 := fmt.Sprintf("tf_test_%s", acctest.RandString(10)) + datasetID2 := fmt.Sprintf("tf_test_%s", acctest.RandString(10)) + datasetID3 := fmt.Sprintf("tf_test_%s", acctest.RandString(10)) + datasetID4 := fmt.Sprintf("tf_test_%s", acctest.RandString(10)) + datasetID5 := fmt.Sprintf("tf_test_%s", acctest.RandString(10)) + datasetID6 := fmt.Sprintf("tf_test_%s", acctest.RandString(10)) + datasetID7 := fmt.Sprintf("tf_test_%s", acctest.RandString(10)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckBigQueryDatasetDestroy, + Steps: []resource.TestStep{ + { + Config: testAccBigQueryRegionalDataset(datasetID1, "asia-east1"), + }, + { + ResourceName: "google_bigquery_dataset.test", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccBigQueryRegionalDataset(datasetID2, "asia-northeast1"), + }, + { + ResourceName: "google_bigquery_dataset.test", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccBigQueryRegionalDataset(datasetID3, "asia-southeast1"), + }, + { + ResourceName: "google_bigquery_dataset.test", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccBigQueryRegionalDataset(datasetID4, "australia-southeast1"), + }, + { + ResourceName: "google_bigquery_dataset.test", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccBigQueryRegionalDataset(datasetID5, "europe-north1"), + }, + { + ResourceName: "google_bigquery_dataset.test", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccBigQueryRegionalDataset(datasetID6, "europe-west2"), + }, + { + ResourceName: "google_bigquery_dataset.test", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccBigQueryRegionalDataset(datasetID7, "us-east4"), + }, + { + ResourceName: "google_bigquery_dataset.test", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccCheckBigQueryDatasetDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) @@ -138,6 +214,22 @@ resource "google_bigquery_dataset" "test" { }`, datasetID) } +func testAccBigQueryRegionalDataset(datasetID string, location string) string { + return fmt.Sprintf(` +resource "google_bigquery_dataset" "test" { + dataset_id = "%s" + friendly_name = "foo" + description = "This is a foo description" + location = "%s" + default_table_expiration_ms = 3600000 + + labels { + env = "foo" + default_table_expiration_ms = 3600000 + } +}`, datasetID, location) +} + func testAccBigQueryDatasetWithOneAccess(datasetID string) string { return fmt.Sprintf(` resource "google_bigquery_dataset" "access_test" { diff --git a/website/docs/r/bigquery_dataset.html.markdown b/website/docs/r/bigquery_dataset.html.markdown index be394886..845d11c9 100644 --- a/website/docs/r/bigquery_dataset.html.markdown +++ b/website/docs/r/bigquery_dataset.html.markdown @@ -60,7 +60,9 @@ The following arguments are supported: multi-regional location is a large geographic area, such as the United States, that contains at least two geographic places - Possible regional values include: `asia-northeast1` + Possible regional values include: `asia-east1`, `asia-northeast1`, `asia-southeast1` + `australia-southeast1`, `europe-north1`, `europe-west2` and `us-east4`. + Possible multi-regional values:`EU` and `US`. The default value is multi-regional location `US`.