From 377329d085b7d29f28eb75f3eb74d5a1bba5378e Mon Sep 17 00:00:00 2001 From: Danny Seymour Date: Tue, 9 Jul 2019 09:04:37 -0700 Subject: [PATCH 1/2] feat: add ability to set the region --- examples/dlp_api_example/main.tf | 18 +++++++++++------- examples/simple_example/main.tf | 2 ++ main.tf | 1 + variables.tf | 7 ++++++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/examples/dlp_api_example/main.tf b/examples/dlp_api_example/main.tf index 3368a12..2741895 100644 --- a/examples/dlp_api_example/main.tf +++ b/examples/dlp_api_example/main.tf @@ -19,7 +19,9 @@ provider "google" { region = "${var.region}" } -resource "random_id" "random_suffix" { byte_length = 4 } +resource "random_id" "random_suffix" { + byte_length = 4 +} locals { gcs_bucket_name = "tmp-dir-bucket-${random_id.random_suffix.hex}" @@ -105,11 +107,12 @@ module "dataflow-job" { project_id = "${var.project_id}" name = "dlp_example_${null_resource.download_sample_cc_into_gcs.id}_${null_resource.deinspection_template_setup.id}" on_delete = "cancel" + region = "${var.region}" zone = "${var.region}-a" template_gcs_path = "gs://dataflow-templates/latest/Stream_DLP_GCS_Text_to_BigQuery" temp_gcs_location = "${module.dataflow-bucket.name}" service_account_email = "${var.service_account_email}" - max_workers = 5 + max_workers = 5 parameters = { inputFilePattern = "gs://${module.dataflow-bucket.name}/cc_records.csv" @@ -120,11 +123,12 @@ module "dataflow-job" { } } -resource "null_resource" "destroy_deidentify_template"{ -provisioner "local-exec" { - when = "destroy" - command = < Date: Tue, 9 Jul 2019 09:50:37 -0700 Subject: [PATCH 2/2] fix: update tests and fix found errors --- examples/simple_example/main.tf | 4 ++-- examples/simple_example/variables.tf | 6 +++++- test/fixtures/simple_example/main.tf | 1 + test/fixtures/simple_example/variables.tf | 6 ++++++ variables.tf | 7 +------ 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/examples/simple_example/main.tf b/examples/simple_example/main.tf index a3e7f28..ad6a3a3 100644 --- a/examples/simple_example/main.tf +++ b/examples/simple_example/main.tf @@ -63,7 +63,7 @@ module "dataflow-job" { name = "wordcount-terraform-example" on_delete = "cancel" region = "${var.region}" - zone = "${var.region}-a" + zone = "${var.zone}" max_workers = 1 template_gcs_path = "gs://dataflow-templates/latest/Word_Count" temp_gcs_location = "${module.dataflow-bucket.name}" @@ -84,7 +84,7 @@ module "dataflow-job-2" { name = "wordcount-terraform-example-2" on_delete = "cancel" region = "${var.region}" - zone = "${var.region}-a" + zone = "${var.zone}" max_workers = 1 template_gcs_path = "gs://dataflow-templates/latest/Word_Count" temp_gcs_location = "${module.dataflow-bucket.name}" diff --git a/examples/simple_example/variables.tf b/examples/simple_example/variables.tf index 06df9db..ee8736e 100644 --- a/examples/simple_example/variables.tf +++ b/examples/simple_example/variables.tf @@ -19,7 +19,11 @@ variable "project_id" { } variable "region" { - description = "The region in which the bucket and the dataflow job will be deployed" + description = "The region in which the bucket will be deployed" +} + +variable "zone" { + description = "The zone in which the dataflow job will be deployed" } variable "service_account_email" { diff --git a/test/fixtures/simple_example/main.tf b/test/fixtures/simple_example/main.tf index 293b8db..932c0f2 100644 --- a/test/fixtures/simple_example/main.tf +++ b/test/fixtures/simple_example/main.tf @@ -18,6 +18,7 @@ module "example" { source = "../../../examples/simple_example" project_id = "${var.project_id}" region = "${var.region}" + zone = "${var.zone}" service_account_email = "${var.service_account_email}" force_destroy = "true" } diff --git a/test/fixtures/simple_example/variables.tf b/test/fixtures/simple_example/variables.tf index 4cbaa16..0ee2894 100644 --- a/test/fixtures/simple_example/variables.tf +++ b/test/fixtures/simple_example/variables.tf @@ -4,6 +4,12 @@ variable "project_id" { variable "region" { description = "The region to deploy to" + default = "us-east1" +} + +variable "zone" { + description = "The zone to deploy to" + default = "us-central1-a" } variable "service_account_email" { diff --git a/variables.tf b/variables.tf index b12e362..a44e2ac 100644 --- a/variables.tf +++ b/variables.tf @@ -45,7 +45,7 @@ variable "on_delete" { } variable "region" { - description = "The region in which the created job should run." + description = "The region in which the created job should run. Also determines the location of the staging bucket if created." default = "us-central1" } @@ -59,11 +59,6 @@ variable "service_account_email" { default = "" } -variable "region" { - description = "The bucket's region location" - default = "us-central1" -} - variable "subnetwork_self_link" { description = "The subnetwork self link to which VMs will be assigned." default = ""