Skip to content

Commit

Permalink
Add ability to import Dataflow jobs (#6386) (#12316)
Browse files Browse the repository at this point in the history
* Add ability to import dataflow jobs

* Update vcr tests to include dataflow job resource state import

* Remove status state ignore

* Remove manual passed importID

* Add properties to ImportStateVerifyIgnore

* add trailing comma to `ImportStateVerifyIgnore` prop

* Ignore state attribute too

Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Aug 16, 2022
1 parent 8f34996 commit f65a2f9
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/6386.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
Add ability to import Dataflow jobs
```
3 changes: 3 additions & 0 deletions google/resource_dataflow_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func resourceDataflowJob() *schema.Resource {
CustomizeDiff: customdiff.All(
resourceDataflowJobTypeCustomizeDiff,
),
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Expand Down
72 changes: 72 additions & 0 deletions google/resource_dataflow_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ func TestAccDataflowJob_basic(t *testing.T) {
testAccDataflowJobExists(t, "google_dataflow_job.big_data"),
),
},
{
ResourceName: "google_dataflow_job.big_data",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "zone", "state"},
},
},
})
}
Expand All @@ -67,6 +73,12 @@ func TestAccDataflowJobSkipWait_basic(t *testing.T) {
testAccDataflowJobExists(t, "google_dataflow_job.big_data"),
),
},
{
ResourceName: "google_dataflow_job.big_data",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "zone", "state"},
},
},
})
}
Expand All @@ -92,6 +104,12 @@ func TestAccDataflowJob_withRegion(t *testing.T) {
testAccRegionalDataflowJobExists(t, "google_dataflow_job.big_data", "us-central1"),
),
},
{
ResourceName: "google_dataflow_job.big_data",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "region", "state"},
},
},
})
}
Expand Down Expand Up @@ -119,6 +137,12 @@ func TestAccDataflowJob_withServiceAccount(t *testing.T) {
testAccDataflowJobHasServiceAccount(t, "google_dataflow_job.big_data", accountId),
),
},
{
ResourceName: "google_dataflow_job.big_data",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "state"},
},
},
})
}
Expand Down Expand Up @@ -146,6 +170,12 @@ func TestAccDataflowJob_withNetwork(t *testing.T) {
testAccDataflowJobHasNetwork(t, "google_dataflow_job.big_data", network),
),
},
{
ResourceName: "google_dataflow_job.big_data",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "state"},
},
},
})
}
Expand Down Expand Up @@ -174,6 +204,12 @@ func TestAccDataflowJob_withSubnetwork(t *testing.T) {
testAccDataflowJobHasSubnetwork(t, "google_dataflow_job.big_data", subnetwork),
),
},
{
ResourceName: "google_dataflow_job.big_data",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "subnetwork", "state"},
},
},
})
}
Expand Down Expand Up @@ -202,6 +238,12 @@ func TestAccDataflowJob_withLabels(t *testing.T) {
testAccDataflowJobHasLabels(t, "google_dataflow_job.with_labels", key),
),
},
{
ResourceName: "google_dataflow_job.with_labels",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "state"},
},
},
})
}
Expand All @@ -227,6 +269,12 @@ func TestAccDataflowJob_withIpConfig(t *testing.T) {
testAccDataflowJobExists(t, "google_dataflow_job.big_data"),
),
},
{
ResourceName: "google_dataflow_job.big_data",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "ip_configuration", "state"},
},
},
})
}
Expand Down Expand Up @@ -255,6 +303,12 @@ func TestAccDataflowJob_withKmsKey(t *testing.T) {
testAccDataflowJobExists(t, "google_dataflow_job.big_data"),
),
},
{
ResourceName: "google_dataflow_job.big_data",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "zone", "state"},
},
},
})
}
Expand All @@ -281,6 +335,12 @@ func TestAccDataflowJobWithAdditionalExperiments(t *testing.T) {
testAccDataflowJobHasExperiments(t, "google_dataflow_job.with_additional_experiments", additionalExperiments),
),
},
{
ResourceName: "google_dataflow_job.with_additional_experiments",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "state"},
},
},
})
}
Expand Down Expand Up @@ -309,6 +369,12 @@ func TestAccDataflowJob_streamUpdate(t *testing.T) {
testAccDataflowJobHasTempLocation(t, "google_dataflow_job.pubsub_stream", "gs://tf-test-bucket2-"+suffix),
),
},
{
ResourceName: "google_dataflow_job.pubsub_stream",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "transform_name_mapping", "state"},
},
},
})
}
Expand Down Expand Up @@ -342,6 +408,12 @@ func TestAccDataflowJob_virtualUpdate(t *testing.T) {
resource.TestCheckResourceAttr("google_dataflow_job.pubsub_stream", "on_delete", "cancel"),
),
},
{
ResourceName: "google_dataflow_job.pubsub_stream",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "state"},
},
},
})
}
Expand Down
6 changes: 5 additions & 1 deletion website/docs/r/dataflow_job.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,8 @@ The following arguments are supported:

## Import

This resource does not support import.
Dataflow jobs can be imported using the job `id` e.g.

```
$ terraform import google_dataflow_job.example 2022-07-31_06_25_42-11926927532632678660
```

0 comments on commit f65a2f9

Please sign in to comment.