diff --git a/spacemk/commands/import_state_files_to_spacelift.py b/spacemk/commands/import_state_files_to_spacelift.py index dd47cd3..0b85d40 100644 --- a/spacemk/commands/import_state_files_to_spacelift.py +++ b/spacemk/commands/import_state_files_to_spacelift.py @@ -44,7 +44,20 @@ def _create_context(spacelift: Spacelift, space_id: str, token: str): --show-error \ --silent \ "${STATE_DOWNLOAD_URL}" -terraform state push -force state.tfstate + +set +e +binary="terraform" +if ! command $binary; then + echo "Terraform is not installed" + binary="tofu" + if ! command $binary; then + echo "OpenTofu is not installed" + exit 1 + fi +fi +set -euo pipefail + +$binary state push -force state.tfstate """ variables = {