2022-01-13 23:38:26 -08:00
|
|
|
# Copyright 2022 Google LLC
|
2021-12-24 02:21:42 -08:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
# https://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.
|
|
|
|
|
|
|
|
output "bq_tables" {
|
|
|
|
description = "Bigquery Tables."
|
|
|
|
value = module.bigquery-dataset.table_ids
|
|
|
|
}
|
|
|
|
|
|
|
|
output "buckets" {
|
2022-01-14 08:56:37 -08:00
|
|
|
description = "GCS bucket Cloud KMS crypto keys."
|
2021-12-24 02:21:42 -08:00
|
|
|
value = {
|
2022-01-14 04:55:47 -08:00
|
|
|
data = module.gcs-data.name
|
|
|
|
df-tmp = module.gcs-df-tmp.name
|
2021-12-24 02:21:42 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-01 23:32:59 -08:00
|
|
|
output "command_01_gcs" {
|
2021-12-24 02:21:42 -08:00
|
|
|
description = "gcloud command to copy data into the created bucket impersonating the service account."
|
2022-01-14 04:55:47 -08:00
|
|
|
value = "gsutil -i ${module.service-account-landing.email} cp data-demo/* ${module.gcs-data.url}"
|
2021-12-24 02:21:42 -08:00
|
|
|
}
|
|
|
|
|
2022-02-01 23:32:59 -08:00
|
|
|
output "command_02_dataflow" {
|
2022-01-14 08:56:37 -08:00
|
|
|
description = "Command to run Dataflow template impersonating the service account."
|
2022-10-25 00:06:58 -07:00
|
|
|
value = templatefile("${path.module}/templates/dataflow.tftpl", {
|
2022-02-01 23:32:59 -08:00
|
|
|
sa_orch_email = module.service-account-orch.email
|
|
|
|
project_id = module.project.project_id
|
|
|
|
region = var.region
|
2022-03-29 06:12:37 -07:00
|
|
|
subnet = local.network_subnet_selflink
|
2022-02-01 23:32:59 -08:00
|
|
|
gcs_df_stg = format("%s/%s", module.gcs-df-tmp.url, "stg")
|
|
|
|
sa_df_email = module.service-account-df.email
|
|
|
|
cmek_encryption = var.cmek_encryption
|
|
|
|
kms_key_df = var.cmek_encryption ? module.kms[0].key_ids.key-df : null
|
|
|
|
gcs_data = module.gcs-data.url
|
|
|
|
data_schema_file = format("%s/%s", module.gcs-data.url, "person_schema.json")
|
|
|
|
data_udf_file = format("%s/%s", module.gcs-data.url, "person_udf.js")
|
|
|
|
data_file = format("%s/%s", module.gcs-data.url, "person.csv")
|
|
|
|
bigquery_dataset = module.bigquery-dataset.dataset_id
|
|
|
|
bigquery_table = module.bigquery-dataset.tables["person"].table_id
|
|
|
|
gcs_df_tmp = format("%s/%s", module.gcs-df-tmp.url, "tmp")
|
|
|
|
})
|
2021-12-24 02:21:42 -08:00
|
|
|
}
|
|
|
|
|
2022-02-01 23:32:59 -08:00
|
|
|
output "command_03_bq" {
|
2022-01-14 08:56:37 -08:00
|
|
|
description = "BigQuery command to query imported data."
|
2022-10-25 00:06:58 -07:00
|
|
|
value = templatefile("${path.module}/templates/bigquery.tftpl", {
|
2022-02-01 23:32:59 -08:00
|
|
|
project_id = module.project.project_id
|
|
|
|
bigquery_dataset = module.bigquery-dataset.dataset_id
|
|
|
|
bigquery_table = module.bigquery-dataset.tables["person"].table_id
|
|
|
|
sql_limit = 1000
|
|
|
|
})
|
2021-12-24 02:21:42 -08:00
|
|
|
}
|
2022-11-19 03:38:37 -08:00
|
|
|
|
|
|
|
output "project_id" {
|
|
|
|
description = "Project id."
|
|
|
|
value = module.project.project_id
|
|
|
|
}
|
|
|
|
|
|
|
|
output "service_accounts" {
|
|
|
|
description = "Service account."
|
|
|
|
value = {
|
|
|
|
bq = module.service-account-bq.email
|
|
|
|
df = module.service-account-df.email
|
|
|
|
orch = module.service-account-orch.email
|
|
|
|
landing = module.service-account-landing.email
|
|
|
|
}
|
|
|
|
}
|