Skip to content

Commit 889dc84

Browse files
committed
🤖 ci: add terraform lint and security scanning
Add Terraform-specific CI coverage gated by changed paths: - terraform fmt and validate - tflint with AWS ruleset plugin - trivy config scanning at HIGH/CRITICAL severity Also add local scanner configuration files under terraform/. --- _Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.27`_ <!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.27 -->
1 parent 251f215 commit 889dc84

3 files changed

Lines changed: 74 additions & 0 deletions

File tree

‎.github/workflows/ci.yaml‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
go: ${{ steps.merge_group_defaults.outputs.go || steps.filter.outputs.go }}
2323
workflows: ${{ steps.merge_group_defaults.outputs.workflows || steps.filter.outputs.workflows }}
2424
publish: ${{ steps.merge_group_defaults.outputs.publish || steps.filter.outputs.publish }}
25+
terraform: ${{ steps.merge_group_defaults.outputs.terraform || steps.filter.outputs.terraform }}
2526
steps:
2627
- name: Checkout
2728
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
@@ -38,6 +39,7 @@ jobs:
3839
echo "go=true"
3940
echo "workflows=true"
4041
echo "publish=false"
42+
echo "terraform=true"
4143
} >> "$GITHUB_OUTPUT"
4244
4345
- name: Detect changed paths
@@ -68,6 +70,9 @@ jobs:
6870
- 'vendor/**'
6971
- 'Dockerfile*'
7072
- 'Dockerfile.goreleaser'
73+
terraform:
74+
- 'terraform/**'
75+
- '.github/workflows/ci.yaml'
7176
7277
lint:
7378
needs: changes
@@ -210,6 +215,57 @@ jobs:
210215
exit 1
211216
fi
212217
218+
terraform:
219+
name: Terraform (fmt/validate/tflint/trivy)
220+
needs: changes
221+
if: github.event_name == 'merge_group' || (needs.changes.outputs.terraform == 'true' && (github.event_name != 'push' || github.actor != 'github-merge-queue[bot]'))
222+
runs-on: depot-ubuntu-24.04
223+
timeout-minutes: 20
224+
permissions:
225+
contents: read
226+
steps:
227+
- name: Checkout
228+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
229+
with:
230+
persist-credentials: false
231+
232+
- name: Setup Terraform
233+
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
234+
with:
235+
terraform_version: 1.11.4
236+
237+
- name: terraform fmt (check)
238+
working-directory: terraform
239+
run: terraform fmt -check -diff -recursive
240+
241+
- name: terraform init (backend disabled)
242+
working-directory: terraform
243+
run: terraform init -backend=false -lockfile=readonly -input=false
244+
245+
- name: terraform validate
246+
working-directory: terraform
247+
run: terraform validate -no-color
248+
249+
- name: Setup TFLint
250+
uses: terraform-linters/setup-tflint@4cb9feea73331a35b422df102992a03a44a3bb33 # v6.2.1
251+
with:
252+
tflint_version: v0.61.0
253+
254+
- name: tflint
255+
working-directory: terraform
256+
run: |
257+
tflint --init
258+
tflint --recursive
259+
260+
- name: Trivy config scan (Terraform)
261+
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # v0.33.1
262+
with:
263+
scan-type: config
264+
scan-ref: terraform/
265+
trivyignores: terraform/.trivyignore
266+
severity: HIGH,CRITICAL
267+
exit-code: '1'
268+
213269
lint-actions:
214270
name: Lint GitHub Actions
215271
needs: changes

‎terraform/.tflint.hcl‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
config {
2+
call_module_type = "all"
3+
}
4+
5+
plugin "aws" {
6+
enabled = true
7+
version = "0.45.0"
8+
source = "github.com/terraform-linters/tflint-ruleset-aws"
9+
}

‎terraform/.trivyignore‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Sandbox EKS clusters intentionally expose the API endpoint publicly for bootstrap simplicity.
2+
AVD-AWS-0040
3+
AVD-AWS-0041
4+
5+
# Sandbox configuration intentionally omits EKS secret envelope encryption.
6+
AVD-AWS-0039
7+
8+
# Public subnets intentionally assign public IPs to support internet-facing resources.
9+
AVD-AWS-0164

0 commit comments

Comments
 (0)