Refactored scripts to focues on compatibility with the real product.

This commit is contained in:
2026-02-28 09:34:52 +01:00
parent c65c347ca5
commit ae7542100b
10 changed files with 135 additions and 246 deletions

View File

@@ -1,4 +1,3 @@
storage_account_name = "terraform"
container_name = "tfstate"
key = "test.tfstate"
use_azuread_auth = true

View File

@@ -1,3 +1,27 @@
#!/usr/bin/env bash
terraform init -backend-config backend.config
ACCESS_KEY=""
while [[ $# -gt 0 ]]; do
case "$1" in
--key|-k)
if [[ ! -f "../accounts.env" ]]; then
echo "Error: accounts.env file not found at ../accounts.env" >&2
exit 1
fi
# Load the accounts.env file to get the ACCESS_KEY variable.
source "../accounts.env"
ACCESS_KEY=$(echo "$AZURITE_ACCOUNTS" | cut -f 1 -d ';' | cut -f 2 -d ':')
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
shift
done
if [[ -z "$ACCESS_KEY" ]]; then
terraform init -backend-config="backend.config" -backend-config="use_azuread_auth=true" -reconfigure
else
terraform init -backend-config="backend.config" -backend-config="access_key=$ACCESS_KEY" -reconfigure
fi