diff --git a/spacemk/commands/import_state_files_to_spacelift.py b/spacemk/commands/import_state_files_to_spacelift.py index dd47cd3..659fb75 100644 --- a/spacemk/commands/import_state_files_to_spacelift.py +++ b/spacemk/commands/import_state_files_to_spacelift.py @@ -37,14 +37,20 @@ def _create_context(spacelift: Spacelift, space_id: str, token: str): "https://app.terraform.io/api/v2/workspaces/${TF_WORKSPACE_ID}/current-state-version" \ | jq -r '.data.attributes."hosted-state-download-url"' ) +echo "Downloading state file from $STATE_DOWNLOAD_URL" + curl --fail \ --header "Authorization: Bearer $TF_TOKEN" \ --location \ --output state.tfstate \ --show-error \ - --silent \ "${STATE_DOWNLOAD_URL}" + +echo "Uploading state file to Spacelift" + terraform state push -force state.tfstate + +echo "State pushed successfully" """ variables = {