Skip to content

Harden service-repo workflows: pin actions, fix Semgrep findings, add docs #43

Harden service-repo workflows: pin actions, fix Semgrep findings, add docs

Harden service-repo workflows: pin actions, fix Semgrep findings, add docs #43

Workflow file for this run

---
name: 'Terraform CI'
on: # yamllint disable-line rule:truthy
pull_request:
concurrency:
group: terraform
cancel-in-progress: false
permissions:
id-token: write # This is required for requesting the JWT
contents: read
pull-requests: write # needed for InfraHouse tool (to make PR comments)
jobs:
terraform:
name: 'Terraform Plan'
runs-on: ubuntu-24.04
environment: production
timeout-minutes: 60
env:
AWS_DEFAULT_REGION: "us-west-1"
ROLE_GITHUB: "arn:aws:iam::303467602807:role/ih-tf-github-control-github"
ROLE_STATE_MANAGER: "arn:aws:iam::289256138624:role/ih-tf-github-control-state-manager"
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.ROLE_GITHUB }}
role-session-name: ih-tf-terraform-control-github-control
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Set Terraform version
id: "terraform_version"
run: echo "IH_TF_VERSION=$(cat .terraform-version)" >> "$GITHUB_OUTPUT"
# Install the $IH_TF_VERSION version of Terraform CLI
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ steps.terraform_version.outputs.IH_TF_VERSION }}
# Prepare Python environment
- name: Setup Python Environment
run: make bootstrap-ci
# Run all required linters
- name: Code Style Check
run: make lint lint/validate
# Generates an execution plan for Terraform
- name: Terraform Plan
run: |
make plan
ih-plan publish \
--github-token ${{ secrets.GITHUB_TOKEN }} \
${{ github.repository }} \
${{ github.event.pull_request.number }} \
plan.stdout plan.stderr
# Upload Terraform Plan
- name: Upload Terraform Plan
run: |
ih-plan --aws-assume-role-arn ${{ env.ROLE_STATE_MANAGER }} \
upload --key-name=plans/${{ github.event.pull_request.number }}.plan tf.plan