Skip to content

Instantly share code, notes, and snippets.

@koliadych
Last active May 10, 2026 12:26
Show Gist options
  • Select an option

  • Save koliadych/1af0feb236132390ea3eae1bab2aaad8 to your computer and use it in GitHub Desktop.

Select an option

Save koliadych/1af0feb236132390ea3eae1bab2aaad8 to your computer and use it in GitHub Desktop.
fintechner tokyo-solo terraform bootstrap
#!/bin/bash
# fintechner — clone the repo into CloudShell and run terraform plan
# for the tokyo-solo env. Reads no secrets, writes nothing to AWS.
set -euo pipefail
REPO=koliadych/fintechner
BRANCH=feature/tokyo-deploy
WORKDIR="$HOME/work"
TFDIR="$WORKDIR/fintechner/infra/envs/tokyo-solo"
echo "=== Installing tools (if missing) ==="
if ! command -v gh >/dev/null 2>&1; then
echo "Installing gh via official RPM repo..."
sudo dnf install -y 'dnf-command(config-manager)' >/dev/null
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo >/dev/null 2>&1 || \
sudo dnf config-manager addrepo --from-repofile=https://cli.github.com/packages/rpm/gh-cli.repo --overwrite
sudo dnf install -y gh --repo gh-cli >/dev/null
fi
if ! command -v terraform >/dev/null 2>&1; then
echo "Installing terraform via official HashiCorp repo..."
sudo dnf install -y 'dnf-command(config-manager)' >/dev/null
sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo >/dev/null 2>&1 || \
sudo dnf config-manager addrepo --from-repofile=https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo --overwrite
sudo dnf install -y terraform >/dev/null
fi
echo " gh: $(gh --version | head -1)"
echo " terraform: $(terraform version | head -1)"
echo " aws-cli: $(aws --version 2>&1 | head -1)"
echo
echo "=== GitHub auth ==="
if gh auth status >/dev/null 2>&1; then
echo "Already authenticated."
else
echo "Not authenticated — starting web device flow."
gh auth login --hostname github.com --git-protocol https --web
fi
# Make git use gh's token instead of asking for a password.
gh auth setup-git --hostname github.com >/dev/null 2>&1
echo "git credential helper configured to use gh."
echo
echo "=== Clone / update repo ==="
mkdir -p "$WORKDIR"
cd "$WORKDIR"
# Always start with a clean clone — wipes any half-done previous attempt.
rm -rf fintechner
gh repo clone "$REPO"
cd fintechner
git checkout "$BRANCH"
echo
echo "=== terraform init ==="
cd "$TFDIR"
terraform init -input=false -upgrade
echo
echo "=== terraform plan ==="
terraform plan -out plan.bin -no-color | tee plan.txt
echo
echo "============================================================"
echo " PLAN COMPLETE"
echo "============================================================"
echo "Plan binary: $TFDIR/plan.bin"
echo "Plan text: $TFDIR/plan.txt"
echo
echo "Send me the 'Plan:' summary line at the bottom + the last ~30 lines."
echo "Do NOT run 'terraform apply' yet."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment