Skip to content

Commit

Permalink
Merge pull request #5 from thefirstofthe300/ds/add-region
Browse files Browse the repository at this point in the history
feat: add ability to set the region
  • Loading branch information
morgante authored Jul 9, 2019
2 parents acb5ca9 + 5df6aaa commit 6628b93
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 16 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
}
}
}
6 changes: 4 additions & 2 deletions examples/simple_example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ module "dataflow-job" {
project_id = "${var.project_id}"
name = "wordcount-terraform-example"
on_delete = "cancel"
zone = "${var.region}-a"
region = "${var.region}"
zone = "${var.zone}"
max_workers = 1
template_gcs_path = "gs://dataflow-templates/latest/Word_Count"
temp_gcs_location = "${module.dataflow-bucket.name}"
Expand All @@ -82,7 +83,8 @@ module "dataflow-job-2" {
project_id = "${var.project_id}"
name = "wordcount-terraform-example-2"
on_delete = "cancel"
zone = "${var.region}-a"
region = "${var.region}"
zone = "${var.zone}"
max_workers = 1
template_gcs_path = "gs://dataflow-templates/latest/Word_Count"
temp_gcs_location = "${module.dataflow-bucket.name}"
Expand Down
6 changes: 5 additions & 1 deletion examples/simple_example/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
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
1 change: 1 addition & 0 deletions test/fixtures/simple_example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
6 changes: 6 additions & 0 deletions test/fixtures/simple_example/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
12 changes: 6 additions & 6 deletions 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. Also determines the location of the staging bucket if created."
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 All @@ -54,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 = ""
Expand Down

0 comments on commit 6628b93

Please sign in to comment.