From 2cd9d97cb77ab24c413ca2fa0aebf738314f35aa Mon Sep 17 00:00:00 2001 From: megan07 Date: Tue, 22 Oct 2019 14:24:43 +0000 Subject: [PATCH] add ip_configuration to dataflow_job Signed-off-by: Modular Magician --- google-beta/resource_dataflow_job.go | 8 ++++ google-beta/resource_dataflow_job_test.go | 45 +++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/google-beta/resource_dataflow_job.go b/google-beta/resource_dataflow_job.go index ff4996b341..1cf0a9eaee 100644 --- a/google-beta/resource_dataflow_job.go +++ b/google-beta/resource_dataflow_job.go @@ -122,6 +122,13 @@ func resourceDataflowJob() *schema.Resource { Optional: true, ForceNew: true, }, + + "ip_configuration": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{"WORKER_IP_PUBLIC", "WORKER_IP_PRIVATE", ""}, false), + }, }, } } @@ -154,6 +161,7 @@ func resourceDataflowJobCreate(d *schema.ResourceData, meta interface{}) error { Subnetwork: d.Get("subnetwork").(string), TempLocation: d.Get("temp_gcs_location").(string), MachineType: d.Get("machine_type").(string), + IpConfiguration: d.Get("ip_configuration").(string), AdditionalUserLabels: labels, Zone: zone, } diff --git a/google-beta/resource_dataflow_job_test.go b/google-beta/resource_dataflow_job_test.go index 37ffc05f18..ae38eeb8d6 100644 --- a/google-beta/resource_dataflow_job_test.go +++ b/google-beta/resource_dataflow_job_test.go @@ -131,6 +131,24 @@ func TestAccDataflowJobCreateWithLabels(t *testing.T) { }) } +func TestAccDataflowJobCreateWithIpConfig(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckDataflowJobDestroy, + Steps: []resource.TestStep{ + { + Config: testAccDataflowJobWithIpConfig, + Check: resource.ComposeTestCheckFunc( + testAccDataflowJobExists( + "google_dataflow_job.big_data"), + ), + }, + }, + }) +} + func testAccCheckDataflowJobDestroy(s *terraform.State) error { for _, rs := range s.RootModule().Resources { if rs.Type != "google_dataflow_job" { @@ -519,6 +537,33 @@ resource "google_dataflow_job" "big_data" { on_delete = "cancel" }`, acctest.RandString(10), acctest.RandString(10), acctest.RandString(10), getTestProjectFromEnv()) +var testAccDataflowJobWithIpConfig = fmt.Sprintf(` +resource "google_storage_bucket" "temp" { + name = "dfjob-test-%s-temp" + + force_destroy = true +} + +resource "google_dataflow_job" "big_data" { + name = "dfjob-test-%s" + + template_gcs_path = "gs://dataflow-templates/wordcount/template_file" + temp_gcs_location = "${google_storage_bucket.temp.url}" + machine_type = "n1-standard-2" + + parameters = { + inputFile = "gs://dataflow-samples/shakespeare/kinglear.txt" + output = "${google_storage_bucket.temp.url}/output" + } + + ip_configuration = "WORKER_IP_PRIVATE" + + zone = "us-central1-f" + project = "%s" + + on_delete = "cancel" +}`, acctest.RandString(10), acctest.RandString(10), getTestProjectFromEnv()) + func testAccDataflowJobWithLabels(key string) string { return fmt.Sprintf(` resource "google_storage_bucket" "temp" {