diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cba0387..3211b33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,6 @@ on: # every commit pushed to main can complete its validation. concurrency: group: ${{ github.workflow }}-${{ github.ref }} - # Only cancel superseded pull request runs. cancel-in-progress: ${{ github.event_name == 'pull_request' }} # CI only needs to read repository contents. @@ -67,4 +66,33 @@ jobs: working-directory: environments/test/frontend run: | tofu init -backend=false -input=false -lockfile=readonly - tofu validate -no-color \ No newline at end of file + tofu validate -no-color + + # Install a pinned TFLint version for static code analysis. + - name: Setup TFLint + uses: terraform-linters/setup-tflint@v6 + with: + tflint_version: v0.64.0 + + # Inspect all OpenTofu root modules and reusable modules. + # Use the shared configuration from the repository root. + - name: Run TFLint + run: | + tflint --init --config="$GITHUB_WORKSPACE/.tflint.hcl" + tflint --recursive --config="$GITHUB_WORKSPACE/.tflint.hcl" --format=compact + + # Install Checkov in an isolated Python environment. + - name: Install Checkov + run: | + python3 -m venv "$RUNNER_TEMP/checkov-venv" + "$RUNNER_TEMP/checkov-venv/bin/python" -m pip install "checkov==3.4.0" + + # Scan OpenTofu configurations and GitHub Actions workflows. + - name: Run Checkov + run: | + "$RUNNER_TEMP/checkov-venv/bin/checkov" \ + --directory . \ + --framework terraform,github_actions \ + --skip-path '\.terraform/' \ + --quiet + diff --git a/.tflint.hcl b/.tflint.hcl new file mode 100644 index 0000000..39ec52b --- /dev/null +++ b/.tflint.hcl @@ -0,0 +1,4 @@ +plugin "terraform" { + enabled = true + preset = "recommended" +} \ No newline at end of file diff --git a/modules/network/providers.tf b/modules/network/providers.tf index 3a3b91e..8cc1f00 100644 --- a/modules/network/providers.tf +++ b/modules/network/providers.tf @@ -1,4 +1,6 @@ terraform { + required_version = ">= 1.12.0" + required_providers { openstack = { source = "terraform-provider-openstack/openstack" diff --git a/modules/vm/providers.tf b/modules/vm/providers.tf index 0b0afd6..651fb40 100644 --- a/modules/vm/providers.tf +++ b/modules/vm/providers.tf @@ -1,4 +1,6 @@ terraform { + required_version = ">= 1.12.0" + required_providers { openstack = { source = "terraform-provider-openstack/openstack"