Skip to content

Commit

Permalink
refactor backend config assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
strickvl committed Sep 21, 2023
1 parent 91d7a0d commit 6aafd39
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 51 deletions.
3 changes: 2 additions & 1 deletion src/mlstacks/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ terraform {
}
}

backend "s3" {
backend "BACKENDREPLACEME" {
bucket = "BUCKETNAMEREPLACEME"
prefix = "terraform/state"
}
Expand Down
8 changes: 3 additions & 5 deletions src/mlstacks/utils/terraform_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6aafd39

Please sign in to comment.