Skip to content

Commit b3ad2c2

Browse files
committed
Add terraform linting workflow
1 parent 60cfef0 commit b3ad2c2

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

.github/workflows/terraform.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: terraform
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
paths:
7+
- "terraform/**"
8+
- ".github/workflows/terraform.yml"
9+
push:
10+
branches:
11+
- master
12+
paths:
13+
- "terraform/**"
14+
- ".github/workflows/terraform.yml"
15+
schedule:
16+
- cron: "0 21 1 * 0"
17+
workflow_dispatch:
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
jobs:
22+
terraform:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
steps:
27+
- uses: actions/checkout@v5
28+
- name: Setup TFLint
29+
uses: terraform-linters/setup-tflint@v4
30+
with:
31+
tflint_version: "latest"
32+
tflint_wrapper: false
33+
- name: Init TFLint
34+
run: tflint --init
35+
env:
36+
GITHUB_TOKEN: ${{ github.token }}
37+
working-directory: ./terraform
38+
- name: Terraform linting
39+
id: tflint
40+
run: tflint -f compact --minimum-failure-severity notice
41+
working-directory: ./terraform

terraform/.tflint.hcl

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

terraform/versions.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,10 @@ terraform {
66
source = "hashicorp/azurerm"
77
version = ">= 4.42.0"
88
}
9+
10+
external = {
11+
source = "hashicorp/external"
12+
version = ">= 2.3.5"
13+
}
914
}
1015
}

0 commit comments

Comments
 (0)