diff --git a/src/mlstacks/cli/cli.py b/src/mlstacks/cli/cli.py index dcbfa27d..b0022379 100644 --- a/src/mlstacks/cli/cli.py +++ b/src/mlstacks/cli/cli.py @@ -85,7 +85,8 @@ def deploy( Args: file (str): Path to the YAML file for deploy - remote_state_bucket_name (str): URL of a pre-existing remote state bucket + remote_state_bucket_name (str): URL of a pre-existing remote + state bucket debug (bool): Flag to enable debug mode to view raw Terraform logging """ with analytics_client.EventHandler(AnalyticsEventsEnum.MLSTACKS_DEPLOY): diff --git a/src/mlstacks/terraform/remote-state-terraform-config/terraform-gcp.tf b/src/mlstacks/terraform/remote-state-terraform-config/terraform-gcp.tf deleted file mode 100644 index 09f69586..00000000 --- a/src/mlstacks/terraform/remote-state-terraform-config/terraform-gcp.tf +++ /dev/null @@ -1,44 +0,0 @@ -# defining the providers for the recipe module -terraform { - required_providers { - google = { - source = "hashicorp/google" - } - - local = { - source = "hashicorp/local" - version = "2.1.0" - } - - null = { - source = "hashicorp/null" - version = "3.1.0" - } - - kubernetes = { - source = "hashicorp/kubernetes" - version = ">= 2.11.0" - } - - kubectl = { - source = "gavinbunney/kubectl" - version = "1.14.0" - } - - htpasswd = { - source = "loafoe/htpasswd" - version = "1.0.3" - } - } - - backend "gcs" { - bucket = "BUCKETNAMEREPLACEME" - prefix = "terraform/state" - } - - required_version = ">= 0.14.8" -} - -provider "google" { - project = var.project_id -} diff --git a/src/mlstacks/terraform/remote-state-terraform-config/terraform-aws.tf b/src/mlstacks/terraform/remote-state-terraform-config/terraform.tf similarity index 95% rename from src/mlstacks/terraform/remote-state-terraform-config/terraform-aws.tf rename to src/mlstacks/terraform/remote-state-terraform-config/terraform.tf index 1fc3c010..e400d4af 100644 --- a/src/mlstacks/terraform/remote-state-terraform-config/terraform-aws.tf +++ b/src/mlstacks/terraform/remote-state-terraform-config/terraform.tf @@ -31,7 +31,7 @@ terraform { } } - backend "s3" { + backend "BACKENDREPLACEME" { bucket = "BUCKETNAMEREPLACEME" prefix = "terraform/state" } diff --git a/src/mlstacks/utils/terraform_utils.py b/src/mlstacks/utils/terraform_utils.py index dcfe5648..cb375554 100644 --- a/src/mlstacks/utils/terraform_utils.py +++ b/src/mlstacks/utils/terraform_utils.py @@ -315,15 +315,13 @@ def populate_tf_definitions( # get the text of the terraform config file from # remote_state_terraform_config_subdir tf_config = Path( - remote_state_terraform_config_subdir - / f"terraform-{provider.value}.tf", + remote_state_terraform_config_subdir / "terraform.tf", ).read_text() - # replace the string "BUCKETNAMEREPLACEME" in the file with - # remote_state_bucket but removing the url prefix + # replace backend config as per provider tf_config = tf_config.replace( "BUCKETNAMEREPLACEME", bucket_name_without_prefix, - ) + ).replace("BACKENDREPLACEME", "s3" if provider == "aws" else "gcs") # write the string to destination_path using filename `terraform.tf` # and overwriting any pre-existing file