#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
export AWS_EC2_METADATA_DISABLED=true
export AWS_ACCESS_KEY_ID=mock
export AWS_SECRET_ACCESS_KEY=mock
unset AWS_SESSION_TOKEN AWS_SECURITY_TOKEN AWS_PROFILE AWS_DEFAULT_PROFILE

tofu fmt -check -recursive
for module in modules/storage modules/region examples/single-host examples/single-region examples/two-regions; do
  tofu -chdir="$module" init -backend=false -input=false -lockfile=readonly -no-color
  tofu -chdir="$module" validate -no-color
  tofu -chdir="$module" test -no-color
done
python3 scripts/check-bootstrap.py
