diff --git a/mmv1/templates/terraform/examples/bigquery_job_copy.tf.erb b/mmv1/templates/terraform/examples/bigquery_job_copy.tf.erb index 1790003b1166..8025df9b886b 100644 --- a/mmv1/templates/terraform/examples/bigquery_job_copy.tf.erb +++ b/mmv1/templates/terraform/examples/bigquery_job_copy.tf.erb @@ -1,6 +1,10 @@ +locals { + count = 2 +} + resource "google_bigquery_table" "source" { deletion_protection = false - count = length(google_bigquery_dataset.source) + count = local.count dataset_id = google_bigquery_dataset.source[count.index].dataset_id table_id = "<%= ctx[:vars]['job_id'] %>_${count.index}_table" @@ -27,7 +31,7 @@ EOF } resource "google_bigquery_dataset" "source" { - count = 2 + count = local.count dataset_id = "<%= ctx[:vars]['job_id'] %>_${count.index}_dataset" friendly_name = "test" diff --git a/mmv1/templates/terraform/examples/bigquery_job_copy_table_reference.tf.erb b/mmv1/templates/terraform/examples/bigquery_job_copy_table_reference.tf.erb index 903e5b398d27..6112d5dee125 100644 --- a/mmv1/templates/terraform/examples/bigquery_job_copy_table_reference.tf.erb +++ b/mmv1/templates/terraform/examples/bigquery_job_copy_table_reference.tf.erb @@ -1,6 +1,10 @@ +locals { + count = 2 +} + resource "google_bigquery_table" "source" { deletion_protection = false - count = length(google_bigquery_dataset.source) + count = local.count dataset_id = google_bigquery_dataset.source[count.index].dataset_id table_id = "<%= ctx[:vars]['job_id'] %>_${count.index}_table" @@ -24,10 +28,12 @@ resource "google_bigquery_table" "source" { } ] EOF + + depends_on = [google_bigquery_dataset.source] } resource "google_bigquery_dataset" "source" { - count = 2 + count = local.count dataset_id = "<%= ctx[:vars]['job_id'] %>_${count.index}_dataset" friendly_name = "test"