Skip to content

Commit

Permalink
Add new regional BigQuery locations.
Browse files Browse the repository at this point in the history
Three more regional locations are supported by BigQuery however the
current validation rejects them.
  • Loading branch information
gh-mlfowler committed Dec 3, 2018
1 parent 2f6b39e commit a636109
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion google/resource_bigquery_dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func resourceBigQueryDataset() *schema.Resource {
Optional: true,
ForceNew: true,
Default: "US",
ValidateFunc: validation.StringInSlice([]string{"US", "EU", "asia-northeast1"}, false),
ValidateFunc: validation.StringInSlice([]string{"US", "EU", "asia-northeast1", "australia-southeast1", "asia-southeast1", "europe-west2"}, false),
},

// DefaultTableExpirationMs: [Optional] The default lifetime of all
Expand Down
65 changes: 65 additions & 0 deletions google/resource_bigquery_dataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,55 @@ 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))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckBigQueryDatasetDestroy,
Steps: []resource.TestStep{
{
Config: testAccBigQueryRegionalDataset(datasetID1, "asia-northeast1"),
},
{
ResourceName: "google_bigquery_dataset.test",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccBigQueryRegionalDataset(datasetID2, "australia-southeast1"),
},
{
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, "europe-west2"),
},
{
ResourceName: "google_bigquery_dataset.test",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccCheckBigQueryDatasetDestroy(s *terraform.State) error {
config := testAccProvider.Meta().(*Config)

Expand Down Expand Up @@ -136,6 +185,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" {
Expand Down

0 comments on commit a636109

Please sign in to comment.