Use tfsec GitHub Action instead of local binary #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: IaC — Terraform Quality & Security | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| workflow_dispatch: {} | |
| jobs: | |
| iac_checks: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: infra | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python (for checkov) | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.9.0 | |
| - name: Install TFLint | |
| uses: terraform-linters/setup-tflint@v4 | |
| with: | |
| tflint_version: latest | |
| - name: tfsec | |
| uses: aquasecurity/[email protected] | |
| with: | |
| working_directory: infra | |
| - name: Install checkov | |
| run: | | |
| pip install --upgrade pip | |
| pip install checkov | |
| - name: Terraform fmt | |
| run: terraform fmt -recursive | |
| - name: Terraform init (providers only) | |
| run: terraform init -backend=false -input=false | |
| - name: Terraform validate | |
| run: terraform validate | |
| - name: TFLint | |
| run: tflint | |
| - name: tfsec | |
| uses: aquasecurity/[email protected] | |
| with: | |
| working_directory: infra | |
| - name: Checkov | |
| run: checkov -d . |