Skip to content

Commit 0d3cae8

Browse files
Add ability to import Dataflow jobs (#6386) (#4595)
* 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 <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent 65f12ef commit 0d3cae8

File tree

4 files changed

+83
-1
lines changed

4 files changed

+83
-1
lines changed

.changelog/6386.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
Add ability to import Dataflow jobs
3+
```

google-beta/resource_dataflow_job.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ func resourceDataflowJob() *schema.Resource {
5959
CustomizeDiff: customdiff.All(
6060
resourceDataflowJobTypeCustomizeDiff,
6161
),
62+
Importer: &schema.ResourceImporter{
63+
State: schema.ImportStatePassthrough,
64+
},
6265
Schema: map[string]*schema.Schema{
6366
"name": {
6467
Type: schema.TypeString,

google-beta/resource_dataflow_job_test.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ func TestAccDataflowJob_basic(t *testing.T) {
4141
testAccDataflowJobExists(t, "google_dataflow_job.big_data"),
4242
),
4343
},
44+
{
45+
ResourceName: "google_dataflow_job.big_data",
46+
ImportState: true,
47+
ImportStateVerify: true,
48+
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "zone", "state"},
49+
},
4450
},
4551
})
4652
}
@@ -67,6 +73,12 @@ func TestAccDataflowJobSkipWait_basic(t *testing.T) {
6773
testAccDataflowJobExists(t, "google_dataflow_job.big_data"),
6874
),
6975
},
76+
{
77+
ResourceName: "google_dataflow_job.big_data",
78+
ImportState: true,
79+
ImportStateVerify: true,
80+
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "zone", "state"},
81+
},
7082
},
7183
})
7284
}
@@ -92,6 +104,12 @@ func TestAccDataflowJob_withRegion(t *testing.T) {
92104
testAccRegionalDataflowJobExists(t, "google_dataflow_job.big_data", "us-central1"),
93105
),
94106
},
107+
{
108+
ResourceName: "google_dataflow_job.big_data",
109+
ImportState: true,
110+
ImportStateVerify: true,
111+
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "region", "state"},
112+
},
95113
},
96114
})
97115
}
@@ -119,6 +137,12 @@ func TestAccDataflowJob_withServiceAccount(t *testing.T) {
119137
testAccDataflowJobHasServiceAccount(t, "google_dataflow_job.big_data", accountId),
120138
),
121139
},
140+
{
141+
ResourceName: "google_dataflow_job.big_data",
142+
ImportState: true,
143+
ImportStateVerify: true,
144+
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "state"},
145+
},
122146
},
123147
})
124148
}
@@ -146,6 +170,12 @@ func TestAccDataflowJob_withNetwork(t *testing.T) {
146170
testAccDataflowJobHasNetwork(t, "google_dataflow_job.big_data", network),
147171
),
148172
},
173+
{
174+
ResourceName: "google_dataflow_job.big_data",
175+
ImportState: true,
176+
ImportStateVerify: true,
177+
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "state"},
178+
},
149179
},
150180
})
151181
}
@@ -174,6 +204,12 @@ func TestAccDataflowJob_withSubnetwork(t *testing.T) {
174204
testAccDataflowJobHasSubnetwork(t, "google_dataflow_job.big_data", subnetwork),
175205
),
176206
},
207+
{
208+
ResourceName: "google_dataflow_job.big_data",
209+
ImportState: true,
210+
ImportStateVerify: true,
211+
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "subnetwork", "state"},
212+
},
177213
},
178214
})
179215
}
@@ -202,6 +238,12 @@ func TestAccDataflowJob_withLabels(t *testing.T) {
202238
testAccDataflowJobHasLabels(t, "google_dataflow_job.with_labels", key),
203239
),
204240
},
241+
{
242+
ResourceName: "google_dataflow_job.with_labels",
243+
ImportState: true,
244+
ImportStateVerify: true,
245+
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "state"},
246+
},
205247
},
206248
})
207249
}
@@ -227,6 +269,12 @@ func TestAccDataflowJob_withIpConfig(t *testing.T) {
227269
testAccDataflowJobExists(t, "google_dataflow_job.big_data"),
228270
),
229271
},
272+
{
273+
ResourceName: "google_dataflow_job.big_data",
274+
ImportState: true,
275+
ImportStateVerify: true,
276+
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "ip_configuration", "state"},
277+
},
230278
},
231279
})
232280
}
@@ -255,6 +303,12 @@ func TestAccDataflowJob_withKmsKey(t *testing.T) {
255303
testAccDataflowJobExists(t, "google_dataflow_job.big_data"),
256304
),
257305
},
306+
{
307+
ResourceName: "google_dataflow_job.big_data",
308+
ImportState: true,
309+
ImportStateVerify: true,
310+
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "zone", "state"},
311+
},
258312
},
259313
})
260314
}
@@ -281,6 +335,12 @@ func TestAccDataflowJobWithAdditionalExperiments(t *testing.T) {
281335
testAccDataflowJobHasExperiments(t, "google_dataflow_job.with_additional_experiments", additionalExperiments),
282336
),
283337
},
338+
{
339+
ResourceName: "google_dataflow_job.with_additional_experiments",
340+
ImportState: true,
341+
ImportStateVerify: true,
342+
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "state"},
343+
},
284344
},
285345
})
286346
}
@@ -309,6 +369,12 @@ func TestAccDataflowJob_streamUpdate(t *testing.T) {
309369
testAccDataflowJobHasTempLocation(t, "google_dataflow_job.pubsub_stream", "gs://tf-test-bucket2-"+suffix),
310370
),
311371
},
372+
{
373+
ResourceName: "google_dataflow_job.pubsub_stream",
374+
ImportState: true,
375+
ImportStateVerify: true,
376+
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "transform_name_mapping", "state"},
377+
},
312378
},
313379
})
314380
}
@@ -342,6 +408,12 @@ func TestAccDataflowJob_virtualUpdate(t *testing.T) {
342408
resource.TestCheckResourceAttr("google_dataflow_job.pubsub_stream", "on_delete", "cancel"),
343409
),
344410
},
411+
{
412+
ResourceName: "google_dataflow_job.pubsub_stream",
413+
ImportState: true,
414+
ImportStateVerify: true,
415+
ImportStateVerifyIgnore: []string{"on_delete", "parameters", "skip_wait_on_job_termination", "state"},
416+
},
345417
},
346418
})
347419
}

website/docs/r/dataflow_job.html.markdown

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,8 @@ The following arguments are supported:
129129

130130
## Import
131131

132-
This resource does not support import.
132+
Dataflow jobs can be imported using the job `id` e.g.
133+
134+
```
135+
$ terraform import google_dataflow_job.example 2022-07-31_06_25_42-11926927532632678660
136+
```

0 commit comments

Comments
 (0)