Skip to content

Commit 990ce41

Browse files
Hotfix | Do not set backend key on tf init --skip-validation (#319)
1 parent 243241b commit 990ce41

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

leverage/modules/tf.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
@click.group()
2323
@pass_state
2424
def tofu(state):
25-
"""Run OpenTofu commands in a custom containerized environment that provides extra functionality when interacting
26-
with your cloud provider such as handling multi factor authentication for you.
25+
"""Run OpenTofu commands in the context of the current project.
2726
All tofu subcommands that receive extra args will pass the given strings as is to their corresponding OpenTofu
2827
counterparts in the container. For example as in `leverage tofu apply -auto-approve` or
2928
`leverage tofu init -reconfigure`
@@ -34,8 +33,7 @@ def tofu(state):
3433
@click.group()
3534
@pass_state
3635
def terraform(state):
37-
"""Run Terraform commands in a custom containerized environment that provides extra functionality when interacting
38-
with your cloud provider such as handling multi factor authentication for you.
36+
"""Run Terraform commands in the context of the current project.
3937
All terraform subcommands that receive extra args will pass the given strings as is to their corresponding Terraform
4038
counterparts in the container. For example as in `leverage terraform apply -auto-approve` or
4139
`leverage terraform init -reconfigure`
@@ -272,7 +270,7 @@ def invoke_for_all_commands(paths, layers, command, *args: Sequence[str], skip_v
272270
validate_for_all_commands(layer, skip_validation=skip_validation)
273271

274272
# set the s3 key
275-
if not get_backend_key(layer / "config.tf"):
273+
if not skip_validation and not get_backend_key(layer / "config.tf"):
276274
backend_key_base = f"{paths.cwd.relative_to(paths.root_dir).as_posix()}/terraform.tfstate"
277275
backend_key = backend_key_base.replace("/base-", "/").replace("/tools-", "/")
278276
set_backend_key(layer / "config.tf", backend_key)

0 commit comments

Comments
 (0)