Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@


# Autogenerated file. DO NOT EDIT.
#
# Copyright (C) 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#


variable "on_delete" {
type = string
description = "One of \"drain\" or \"cancel\". Specifies behavior of deletion during terraform destroy."
}

variable "project" {
type = string
description = "The Google Cloud Project ID within which this module provisions resources."
}

variable "region" {
type = string
description = "The region in which the created job should run."
}

variable "gcsInputDirectory" {
type = string
description = "This directory is used to read the AVRO files of the records read from source. For example, `gs://your-bucket/your-path`"
default = null
}

variable "projectId" {
type = string
description = "This is the name of the Cloud Spanner project."
default = null
}

variable "spannerHost" {
type = string
description = "The Cloud Spanner endpoint to call in the template. For example, `https://batch-spanner.googleapis.com`. Defaults to: https://batch-spanner.googleapis.com."
default = null
}

variable "instanceId" {
type = string
description = "The destination Cloud Spanner instance."

}

variable "databaseId" {
type = string
description = "The destination Cloud Spanner database."

}

variable "spannerPriority" {
type = string
description = "The request priority for Cloud Spanner calls. The value must be one of: [`HIGH`,`MEDIUM`,`LOW`]. Defaults to `HIGH`."
default = null
}

variable "sessionFilePath" {
type = string
description = "Session file path in Cloud Storage that contains mapping information from Spanner Migration Tool. Defaults to empty."
default = null
}

variable "schemaOverridesFilePath" {
type = string
description = "A file which specifies the table and the column name overrides from source to spanner. Defaults to empty."
default = null
}

variable "tableOverrides" {
type = string
description = "These are the table name overrides from source to spanner. They are written in thefollowing format: [{SourceTableName1, SpannerTableName1}, {SourceTableName2, SpannerTableName2}]This example shows mapping Singers table to Vocalists and Albums table to Records. For example, `[{Singers, Vocalists}, {Albums, Records}]`. Defaults to empty."
default = null
}

variable "columnOverrides" {
type = string
description = "These are the column name overrides from source to spanner. They are written in thefollowing format: [{SourceTableName1.SourceColumnName1, SourceTableName1.SpannerColumnName1}, {SourceTableName2.SourceColumnName1, SourceTableName2.SpannerColumnName1}]Note that the SourceTableName should remain the same in both the source and spanner pair. To override table names, use tableOverrides.The example shows mapping SingerName to TalentName and AlbumName to RecordName in Singers and Albums table respectively. For example, `[{Singers.SingerName, Singers.TalentName}, {Albums.AlbumName, Albums.RecordName}]`. Defaults to empty."
default = null
}

variable "bigQueryDataset" {
type = string
description = "The BigQuery dataset ID where the validation results will be stored. For example, `validation_report_dataset`"

}

variable "runId" {
type = string
description = "A unique identifier for the validation run. If not provided, the Dataflow Job Name will be used. For example, `run_20230101_120000`"
default = null
}

variable "transformationJarPath" {
type = string
description = "Custom jar location in Cloud Storage that contains the custom transformation logic for processing records. Defaults to empty."
default = null
}

variable "transformationClassName" {
type = string
description = "Fully qualified class name having the custom transformation logic. It is a mandatory field in case transformationJarPath is specified. Defaults to empty."
default = null
}

variable "transformationCustomParameters" {
type = string
description = "String containing any custom parameters to be passed to the custom transformation class. Defaults to empty."
default = null
}


provider "google" {
project = var.project
}

provider "google-beta" {
project = var.project
}

variable "additional_experiments" {
type = set(string)
description = "List of experiments that should be used by the job. An example value is 'enable_stackdriver_agent_metrics'."
default = null
}

variable "autoscaling_algorithm" {
type = string
description = "The algorithm to use for autoscaling"
default = null
}

variable "enable_streaming_engine" {
type = bool
description = "Indicates if the job should use the streaming engine feature."
default = null
}

variable "ip_configuration" {
type = string
description = "The configuration for VM IPs. Options are 'WORKER_IP_PUBLIC' or 'WORKER_IP_PRIVATE'."
default = null
}

variable "kms_key_name" {
type = string
description = "The name for the Cloud KMS key for the job. Key format is: projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY"
default = null
}

variable "labels" {
type = map(string)
description = "User labels to be specified for the job. Keys and values should follow the restrictions specified in the labeling restrictions page. NOTE: This field is non-authoritative, and will only manage the labels present in your configuration. Please refer to the field 'effective_labels' for all of the labels present on the resource."
default = null
}

variable "launcher_machine_type" {
type = string
description = "The machine type to use for launching the job. The default is n1-standard-1."
default = null
}

variable "machine_type" {
type = string
description = "The machine type to use for the job."
default = null
}

variable "max_workers" {
type = number
description = "The maximum number of Google Compute Engine instances to be made available to your pipeline during execution, from 1 to 1000."
default = null
}

variable "name" {
type = string
}

variable "network" {
type = string
description = "The network to which VMs will be assigned. If it is not provided, 'default' will be used."
default = null
}

variable "num_workers" {
type = number
description = "The initial number of Google Compute Engine instances for the job."
default = null
}

variable "sdk_container_image" {
type = string
description = "Docker registry location of container image to use for the 'worker harness. Default is the container for the version of the SDK. Note this field is only valid for portable pipelines."
default = null
}

variable "service_account_email" {
type = string
description = "The Service Account email used to create the job."
default = null
}

variable "skip_wait_on_job_termination" {
type = bool
description = "If true, treat DRAINING and CANCELLING as terminal job states and do not wait for further changes before removing from terraform state and moving on. WARNING: this will lead to job name conflicts if you do not ensure that the job names are different, e.g. by embedding a release ID or by using a random_id."
default = null
}

variable "staging_location" {
type = string
description = "The Cloud Storage path to use for staging files. Must be a valid Cloud Storage URL, beginning with gs://."
default = null
}

variable "subnetwork" {
type = string
description = "The subnetwork to which VMs will be assigned. Should be of the form 'regions/REGION/subnetworks/SUBNETWORK'."
default = null
}

variable "temp_location" {
type = string
description = "The Cloud Storage path to use for temporary files. Must be a valid Cloud Storage URL, beginning with gs://."
default = null
}

resource "google_project_service" "required" {
service = "dataflow.googleapis.com"
disable_on_destroy = false
}

resource "google_dataflow_flex_template_job" "generated" {
depends_on = [google_project_service.required]
provider = google-beta
container_spec_gcs_path = "gs://dataflow-templates-${var.region}/latest/flex/GCS_Spanner_Data_Validator"
parameters = {
gcsInputDirectory = var.gcsInputDirectory
projectId = var.projectId
spannerHost = var.spannerHost
instanceId = var.instanceId
databaseId = var.databaseId
spannerPriority = var.spannerPriority
sessionFilePath = var.sessionFilePath
schemaOverridesFilePath = var.schemaOverridesFilePath
tableOverrides = var.tableOverrides
columnOverrides = var.columnOverrides
bigQueryDataset = var.bigQueryDataset
runId = var.runId
transformationJarPath = var.transformationJarPath
transformationClassName = var.transformationClassName
transformationCustomParameters = var.transformationCustomParameters
}

additional_experiments = var.additional_experiments
autoscaling_algorithm = var.autoscaling_algorithm
enable_streaming_engine = var.enable_streaming_engine
ip_configuration = var.ip_configuration
kms_key_name = var.kms_key_name
labels = var.labels
launcher_machine_type = var.launcher_machine_type
machine_type = var.machine_type
max_workers = var.max_workers
name = var.name
network = var.network
num_workers = var.num_workers
sdk_container_image = var.sdk_container_image
service_account_email = var.service_account_email
skip_wait_on_job_termination = var.skip_wait_on_job_termination
staging_location = var.staging_location
subnetwork = var.subnetwork
temp_location = var.temp_location
region = var.region
}

output "dataflow_job_url" {
value = "https://console.cloud.google.com/dataflow/jobs/${var.region}/${google_dataflow_flex_template_job.generated.job_id}"
}

Loading
Loading