From a1cd54aa69f15f63a7374f040b8e7851476067f8 Mon Sep 17 00:00:00 2001 From: Charlie Wang <2144018+kingman@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:27:07 +0200 Subject: [PATCH] Fix poetry dependencies (#42) * remove unnecessary dependency declarations * automatic terraform validation * refactor to not use depends_on on modules * fix dependency to rely on attribute that exists after files are generated * fix conditional expression --- infrastructure/terraform/main.tf | 14 +++++--------- .../terraform/modules/activation/main.tf | 9 --------- .../terraform/modules/activation/variables.tf | 7 ++++++- .../terraform/modules/feature-store/main.tf | 3 +-- .../terraform/modules/feature-store/variables.tf | 5 +++++ .../terraform/modules/pipelines/variables.tf | 7 ++++++- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/infrastructure/terraform/main.tf b/infrastructure/terraform/main.tf index 94271e9c..91dfc436 100644 --- a/infrastructure/terraform/main.tf +++ b/infrastructure/terraform/main.tf @@ -109,24 +109,19 @@ resource "null_resource" "generate_sql_queries" { module "feature_store" { source = "./modules/feature-store" - config_file_path = local_file.feature_store_configuration.filename + config_file_path = local_file.feature_store_configuration.id != "" ? local_file.feature_store_configuration.filename : "" enabled = var.deploy_feature_store count = var.deploy_feature_store ? 1 : 0 project_id = var.feature_store_project_id - - depends_on = [ - null_resource.generate_sql_queries - ] + sql_dir_input = null_resource.generate_sql_queries.id != "" ? "${local.source_root_dir}/sql" : "" } module "pipelines" { source = "./modules/pipelines" - config_file_path = local_file.feature_store_configuration.filename + config_file_path = local_file.feature_store_configuration.id != "" ? local_file.feature_store_configuration.filename : "" poetry_run_alias = local.poetry_run_alias count = var.deploy_pipelines ? 1 : 0 - depends_on = [ - null_resource.poetry_install - ] + poetry_installed = null_resource.poetry_install.id } module "activation" { @@ -140,4 +135,5 @@ module "activation" { ga4_property_id = var.ga4_property_id ga4_stream_id = var.ga4_stream_id count = var.deploy_activation ? 1 : 0 + poetry_installed = null_resource.poetry_install.id } diff --git a/infrastructure/terraform/modules/activation/main.tf b/infrastructure/terraform/modules/activation/main.tf index 61354f39..3a9b583e 100644 --- a/infrastructure/terraform/modules/activation/main.tf +++ b/infrastructure/terraform/modules/activation/main.tf @@ -38,13 +38,6 @@ locals { } -resource "null_resource" "poetry_install" { - provisioner "local-exec" { - command = "${var.poetry_cmd} install" - working_dir = local.source_root_dir - } -} - module "project_services" { source = "terraform-google-modules/project-factory/google//modules/project_services" version = "14.1.0" @@ -69,8 +62,6 @@ module "project_services" { "datapipelines.googleapis.com", "analyticsadmin.googleapis.com", ] - - depends_on = [ null_resource.poetry_install ] } module "bigquery" { diff --git a/infrastructure/terraform/modules/activation/variables.tf b/infrastructure/terraform/modules/activation/variables.tf index 1fbc8df3..fa097d0e 100644 --- a/infrastructure/terraform/modules/activation/variables.tf +++ b/infrastructure/terraform/modules/activation/variables.tf @@ -58,4 +58,9 @@ variable "ga4_property_id" { variable "ga4_stream_id" { description = "Google Analytics data stream id" type = string -} \ No newline at end of file +} + +variable "poetry_installed" { + description = "Construct to specify dependency to poetry installed" + type = string +} diff --git a/infrastructure/terraform/modules/feature-store/main.tf b/infrastructure/terraform/modules/feature-store/main.tf index 5ee6cd31..66c0c1d2 100644 --- a/infrastructure/terraform/modules/feature-store/main.tf +++ b/infrastructure/terraform/modules/feature-store/main.tf @@ -24,8 +24,7 @@ locals { audience_segmentation_project_id = local.config_vars.bigquery.dataset.audience_segmentation.project_id customer_lifetime_value_project_id = local.config_vars.bigquery.dataset.customer_lifetime_value.project_id project_id = local.feature_store_project_id - source_root_dir = "../.." - sql_dir = "${local.source_root_dir}/sql" + sql_dir = var.sql_dir_input builder_repository_id = "marketing-data-engine-base-repo" cloud_build_service_account_name = "cloud-builder-runner" cloud_build_service_account_email = "${local.cloud_build_service_account_name}@${local.project_id}.iam.gserviceaccount.com" diff --git a/infrastructure/terraform/modules/feature-store/variables.tf b/infrastructure/terraform/modules/feature-store/variables.tf index fa721c7d..5b6c8ae7 100644 --- a/infrastructure/terraform/modules/feature-store/variables.tf +++ b/infrastructure/terraform/modules/feature-store/variables.tf @@ -32,3 +32,8 @@ variable "project_id" { type = string description = "Google Cloud Project ID" } + +variable "sql_dir_input" { + type = string + description = "SQL queries directory" +} diff --git a/infrastructure/terraform/modules/pipelines/variables.tf b/infrastructure/terraform/modules/pipelines/variables.tf index 9bb37df2..13b974a8 100644 --- a/infrastructure/terraform/modules/pipelines/variables.tf +++ b/infrastructure/terraform/modules/pipelines/variables.tf @@ -20,4 +20,9 @@ variable "config_file_path" { variable "poetry_run_alias" { description = "alias for poetry run command on the current system" type = string -} \ No newline at end of file +} + +variable "poetry_installed" { + description = "Construct to specify dependency to poetry installed" + type = string +}