A pre-commit hook is installed at .git/hooks/pre-commit that blocks commits containing:
- Sensitive file patterns (
*.auto.tfvars,*.pem,.env, etc.) - API keys, passwords, and AWS credentials in file content
-
Rotate immediately:
./scripts/rotate-api-keys.sh
-
Update Secrets Manager:
cd infra terraform apply # Updates AWS Secrets Manager with new keys
-
Remove from Git history (if already pushed):
# Use BFG Repo-Cleaner or git-filter-repo git filter-repo --path infra/guestbook.auto.tfvars --invert-paths git push --force -
Notify team if this is a shared repository
- Never commit
.auto.tfvarsfiles - Use.exampletemplates instead - Use AWS Secrets Manager for all sensitive data
- Generate strong keys:
openssl rand -hex 32 - Rotate keys regularly (every 90 days minimum)
- Enable GitHub secret scanning for public repos
- Use IRSA for pod-level AWS access instead of embedding credentials
*.auto.tfvarsterraform.tfvars.env(use.env.example)*.pem,*.key- Any file with
secretorpasswordin the name
Test the pre-commit hook:
# This should be blocked
echo 'api_key = "abc123"' > test.auto.tfvars
git add test.auto.tfvars
git commit -m "test" # Should fail