Skip to content

Commit

Permalink
refacto: moved db password gen away from top level
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisVLRT committed May 21, 2021
1 parent 1f3155a commit 585a8a2
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 20 deletions.
5 changes: 0 additions & 5 deletions IaC/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ resource "random_id" "artifacts_bucket_name_suffix" {
byte_length = 5
}

resource "random_password" "password" {
length = 16
}

module "network" {
source = "./modules/network"
network_name = var.network_name
Expand All @@ -49,7 +45,6 @@ module "mlflow" {
source = "./modules/mlflow"
mlflow_server = var.mlflow_server
artifacts_bucket_name = "${var.artifacts_bucket}-${random_id.artifacts_bucket_name_suffix.hex}"
db_password_value = random_password.password.result
server_docker_image = var.mlflow_docker_image
project_id = var.project_id
consent_screen_support_email = var.consent_screen_support_email
Expand Down
2 changes: 1 addition & 1 deletion IaC/modules/mlflow/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

module "artifacts" {
source = "./artifacts"
bucket_name = var.artifacts_bucket_name
Expand All @@ -26,7 +27,6 @@ module "artifacts" {
module "db_secret" {
source = "./secret_manager"
secret_id = var.db_password_name
secret_value = var.db_password_value
}

module "database" {
Expand Down
8 changes: 6 additions & 2 deletions IaC/modules/mlflow/secret_manager/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

resource "random_password" "password" {
length = 16
}

resource "google_secret_manager_secret" "secret" {
provider = google-beta

Expand All @@ -25,12 +30,11 @@ resource "google_secret_manager_secret" "secret" {
}
}


resource "google_secret_manager_secret_version" "secret-version" {
provider = google-beta

secret = google_secret_manager_secret.secret.id

secret_data = var.secret_value
secret_data = random_password.password.result
depends_on = [google_secret_manager_secret.secret]
}
4 changes: 0 additions & 4 deletions IaC/modules/mlflow/secret_manager/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ variable "secret_id" {
type = string
description = "Name of the secret you want to create"
}
variable "secret_value" {
type = string
description = "value of the secret you want to create"
}
variable "module_depends_on" {
type = any
default = null
Expand Down
4 changes: 0 additions & 4 deletions IaC/modules/mlflow/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ variable "db_password_name" {
type = string
default = "mlflow-db-pwd"
}
variable "db_password_value" {
description = "Value of the database password stored in secret manager"
type = string
}
variable "db_username" {
description = "Value of the database username"
type = string
Expand Down
4 changes: 0 additions & 4 deletions IaC/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ variable "artifacts_bucket" {
type = string
default = "oneclick-mlflow-store"
}
variable "db_password_value" {
description = "Database password to connect to your instance"
type = string
}
variable "mlflow_docker_image" {
description = "Docker image used in container registry"
type = string
Expand Down

0 comments on commit 585a8a2

Please sign in to comment.