Skip to content

Commit

Permalink
feat: add ability to set the region
Browse files Browse the repository at this point in the history
  • Loading branch information
thefirstofthe300 committed Jul 9, 2019
1 parent acb5ca9 commit 377329d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
18 changes: 11 additions & 7 deletions examples/dlp_api_example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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"
Expand All @@ -120,11 +123,12 @@ module "dataflow-job" {
}
}

resource "null_resource" "destroy_deidentify_template"{
provisioner "local-exec" {
when = "destroy"
command = <<EOF
resource "null_resource" "destroy_deidentify_template" {
provisioner "local-exec" {
when = "destroy"

command = <<EOF
curl -s -X DELETE "https://dlp.googleapis.com/v2/projects/${var.project_id}/deidentifyTemplates/15" -H "Authorization:Bearer $(gcloud auth application-default print-access-token)"
EOF
}
}
}
2 changes: 2 additions & 0 deletions examples/simple_example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module "dataflow-job" {
project_id = "${var.project_id}"
name = "wordcount-terraform-example"
on_delete = "cancel"
region = "${var.region}"
zone = "${var.region}-a"
max_workers = 1
template_gcs_path = "gs://dataflow-templates/latest/Word_Count"
Expand All @@ -82,6 +83,7 @@ module "dataflow-job-2" {
project_id = "${var.project_id}"
name = "wordcount-terraform-example-2"
on_delete = "cancel"
region = "${var.region}"
zone = "${var.region}-a"
max_workers = 1
template_gcs_path = "gs://dataflow-templates/latest/Word_Count"
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
resource "google_dataflow_job" "dataflow_job" {
provider = "google"
project = "${var.project_id}"
region = "${var.region}"
zone = "${var.zone}"
name = "${var.name}"
on_delete = "${var.on_delete}"
Expand Down
7 changes: 6 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ variable "on_delete" {
default = "cancel"
}

variable "region" {
description = "The region in which the created job should run."
default = "us-central1"
}

variable "zone" {
description = "The zone in which the created job should run. If it is not provided, the provider zone is used."
description = "The zone in which the created job should run."
default = "us-central1-a"
}

Expand Down

0 comments on commit 377329d

Please sign in to comment.