Skip to content

Commit

Permalink
Fix poetry dependencies (GoogleCloudPlatform#42)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
kingman authored Sep 6, 2023
1 parent 1bdaae5 commit a1cd54a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
14 changes: 5 additions & 9 deletions infrastructure/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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
}
9 changes: 0 additions & 9 deletions infrastructure/terraform/modules/activation/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -69,8 +62,6 @@ module "project_services" {
"datapipelines.googleapis.com",
"analyticsadmin.googleapis.com",
]

depends_on = [ null_resource.poetry_install ]
}

module "bigquery" {
Expand Down
7 changes: 6 additions & 1 deletion infrastructure/terraform/modules/activation/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ variable "ga4_property_id" {
variable "ga4_stream_id" {
description = "Google Analytics data stream id"
type = string
}
}

variable "poetry_installed" {
description = "Construct to specify dependency to poetry installed"
type = string
}
3 changes: 1 addition & 2 deletions infrastructure/terraform/modules/feature-store/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions infrastructure/terraform/modules/feature-store/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ variable "project_id" {
type = string
description = "Google Cloud Project ID"
}

variable "sql_dir_input" {
type = string
description = "SQL queries directory"
}
7 changes: 6 additions & 1 deletion infrastructure/terraform/modules/pipelines/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ variable "config_file_path" {
variable "poetry_run_alias" {
description = "alias for poetry run command on the current system"
type = string
}
}

variable "poetry_installed" {
description = "Construct to specify dependency to poetry installed"
type = string
}

0 comments on commit a1cd54a

Please sign in to comment.