Skip to content

Commit

Permalink
ci: rewrite SSH module URLs to HTTPS in terraform-validate workflow
Browse files Browse the repository at this point in the history
In the GitHub Actions CI environment, the runner has no SSH key configured
for github.e.it.census.gov, so 'terraform init' fails when pulling modules
whose source URLs use the SSH git@ scheme (e.g. tags.tf, examples/simple/eks.tf).

Changes made to .github/workflows/terraform-validate.yaml:

1. Added 'Setup GITHUB Credentials' step (CSVD/gh-auth@main)
   - Obtains a short-lived GitHub App token using the repository's
     GH_APP_PEM_FILE secret and GH_APP_ID / GH_APP_INSTALLATION_ID vars.
   - This mirrors the credential setup already present in the release workflow.

2. Added 'Configure Git HTTPS for Terraform module pulls' step
   - Runs: git config --global url."https://oauth2:<token>@github.e.it.census.gov/".insteadOf "git@github.e.it.census.gov:"
   - This tells git to transparently rewrite any SSH git@ URL for this host
     to an authenticated HTTPS URL at the transport layer.
   - Terraform shells out to the system git binary for module fetches, so
     it honours this rewrite without any changes to .tf source URLs.

No .tf files are modified: SSH source URLs in tags.tf and examples/simple/eks.tf
remain intact so that developers using SSH keys locally are unaffected.
  • Loading branch information
Dave Arnold committed Jun 24, 2026
1 parent bc60984 commit 0d10483
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/terraform-validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ jobs:
- name: Checkout code
uses: CSVD/gh-actions-checkout@v4

- name: Setup GITHUB Credentials
id: github_credentials
uses: CSVD/gh-auth@main
with:
github_app_pem_file: ${{ secrets.GH_APP_PEM_FILE }}
github_app_installation_id: ${{ vars.GH_APP_INSTALLATION_ID }}
github_app_id: ${{ vars.GH_APP_ID }}

- name: Configure Git HTTPS for Terraform module pulls
run: |
git config --global url."https://oauth2:${{ steps.github_credentials.outputs.github_token }}@github.e.it.census.gov/".insteadOf "git@github.e.it.census.gov:"
- name: Setup Terraform
uses: CSVD/gh-actions-setup-terraform@v2
with:
Expand Down

0 comments on commit 0d10483

Please sign in to comment.