diff --git a/spacemk/commands/import_state_files_to_spacelift.py b/spacemk/commands/import_state_files_to_spacelift.py index dd47cd3..2dc7568 100644 --- a/spacemk/commands/import_state_files_to_spacelift.py +++ b/spacemk/commands/import_state_files_to_spacelift.py @@ -44,7 +44,19 @@ def _create_context(spacelift: Spacelift, space_id: str, token: str): --show-error \ --silent \ "${STATE_DOWNLOAD_URL}" -terraform state push -force state.tfstate + +binary="terraform" +if ! command -v $binary &> /dev/null; then + echo "Terraform not found, using OpenTofu" + binary="tofu" + if ! command -v $binary &> /dev/null; then + echo "OpenTofu not found, Failing run..." + exit 1 + fi +fi + +echo "Using Binary: $binary" +$binary state push -force state.tfstate """ variables = {