Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions databases/azure-cosmos-db/scripts/azure/do_tofu
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ set -eoux pipefail

env | grep -E '^(AZURE|ARM)' || true

# Ensure tofu is available. On agents where tofu is not pre-installed, download
# and cache the binary in /tmp/np-tofu-bin so it is only fetched once per pod
# lifetime (the directory survives across actions but is cleared on pod restart).
if ! command -v tofu &>/dev/null; then
TOFU_VERSION="1.9.0"
TOFU_BIN_DIR="/tmp/np-tofu-bin"
TOFU_BIN="$TOFU_BIN_DIR/tofu"

if [ ! -f "$TOFU_BIN" ]; then
echo "tofu not found in PATH, installing v${TOFU_VERSION} to ${TOFU_BIN_DIR}..."
mkdir -p "$TOFU_BIN_DIR"
curl -fsSL \
"https://github.com/opentofu/opentofu/releases/download/v${TOFU_VERSION}/tofu_${TOFU_VERSION}_linux_amd64.zip" \
-o /tmp/tofu.zip
unzip -qo /tmp/tofu.zip tofu -d "$TOFU_BIN_DIR"
chmod +x "$TOFU_BIN"
rm -f /tmp/tofu.zip
echo "tofu installed: $("$TOFU_BIN" version | head -1)"
else
echo "Using cached tofu at ${TOFU_BIN}"
fi

export PATH="$TOFU_BIN_DIR:$PATH"
fi

TOFU_VAR_FILE="$OUTPUT_DIR/terraform.tfvars.json"

echo "$TOFU_VARIABLES" > "$TOFU_VAR_FILE"
Expand Down
Loading