File tree Expand file tree Collapse file tree 15 files changed +725
-96
lines changed
examples/vpc-for-ingress-egress-gw Expand file tree Collapse file tree 15 files changed +725
-96
lines changed Original file line number Diff line number Diff line change 1+ name : Terraform Lint
2+
3+ on :
4+ push :
5+ branches : [ main, develop ]
6+ pull_request :
7+ branches : [ main ]
8+
9+ jobs :
10+ tflint :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - uses : actions/checkout@v4
15+
16+ - name : Cache plugin dir
17+ uses : actions/cache@v3
18+ with :
19+ path : ~/.tflint.d/plugins
20+ key : ${{ hashFiles('.tflint.hcl') }}
21+
22+ - uses : terraform-linters/setup-tflint@v4
23+ with :
24+ tflint_version : v0.50.3
25+
26+ - name : Show version
27+ run : tflint --version
28+
29+ - name : Init TFLint
30+ run : tflint --init
31+
32+ - name : Run TFLint
33+ run : tflint --format compact
34+
35+ - name : Run TFLint on modules
36+ run : |
37+ find . -name "*.tf" -exec dirname {} \; | sort -u | while read dir; do
38+ echo "Linting $dir"
39+ (cd "$dir" && tflint --format compact)
40+ done
41+
42+ terraform-fmt :
43+ runs-on : ubuntu-latest
44+
45+ steps :
46+ - uses : actions/checkout@v4
47+
48+ - uses : hashicorp/setup-terraform@v3
49+ with :
50+ terraform_version : " 1.8.0"
51+
52+ - name : Terraform Format Check
53+ run : terraform fmt -check -recursive -diff
54+
55+ terraform-validate :
56+ runs-on : ubuntu-latest
57+
58+ steps :
59+ - uses : actions/checkout@v4
60+
61+ - uses : hashicorp/setup-terraform@v3
62+ with :
63+ terraform_version : " 1.8.0"
64+
65+ - name : Terraform Init
66+ run : terraform init -backend=false
67+
68+ - name : Terraform Validate
69+ run : terraform validate
Original file line number Diff line number Diff line change 1+ plugin "terraform" {
2+ enabled = true
3+ preset = " recommended"
4+ }
5+
6+ plugin "aws" {
7+ enabled = true
8+ version = " 0.29.0"
9+ source = " github.com/terraform-linters/tflint-ruleset-aws"
10+ }
11+
12+ rule "terraform_deprecated_interpolation" {
13+ enabled = true
14+ }
15+
16+ rule "terraform_unused_declarations" {
17+ enabled = true
18+ }
19+
20+ rule "terraform_comment_syntax" {
21+ enabled = true
22+ }
23+
24+ rule "terraform_documented_outputs" {
25+ enabled = true
26+ }
27+
28+ rule "terraform_documented_variables" {
29+ enabled = true
30+ }
31+
32+ rule "terraform_typed_variables" {
33+ enabled = true
34+ }
35+
36+ rule "terraform_module_pinned_source" {
37+ enabled = true
38+ }
39+
40+ rule "terraform_naming_convention" {
41+ enabled = true
42+ format = " snake_case"
43+ }
44+
45+ rule "terraform_standard_module_structure" {
46+ enabled = true
47+ }
48+
49+ # AWS-specific rules
50+ rule "aws_resource_missing_tags" {
51+ enabled = true
52+ tags = [" Name" , " Environment" ]
53+ }
54+
55+ rule "aws_instance_invalid_type" {
56+ enabled = true
57+ }
58+
59+ rule "aws_security_group_rule_invalid_protocol" {
60+ enabled = true
61+ }
Original file line number Diff line number Diff line change 1+ {
2+ "recommendations" : [
3+ " hashicorp.terraform"
4+ ]
5+ }
Original file line number Diff line number Diff line change 1+ {
2+ "terraform.validation.enableEnhancedValidation" : true ,
3+ "terraform.languageServer.enable" : true ,
4+ "terraform.codelens.referenceCount" : true ,
5+ "files.associations" : {
6+ "*.tf" : " terraform" ,
7+ "*.tfvars" : " terraform" ,
8+ "*.tfvars.example" : " terraform" ,
9+ ".tflint.hcl" : " hcl"
10+ },
11+ "editor.formatOnSave" : true ,
12+ "editor.codeActionsOnSave" : {
13+ "source.formatDocument" : " explicit"
14+ },
15+ "[terraform]" : {
16+ "editor.defaultFormatter" : " hashicorp.terraform" ,
17+ "editor.formatOnSave" : true ,
18+ "editor.insertSpaces" : true ,
19+ "editor.tabSize" : 2
20+ },
21+ "[hcl]" : {
22+ "editor.defaultFormatter" : " hashicorp.terraform" ,
23+ "editor.formatOnSave" : true ,
24+ "editor.insertSpaces" : true ,
25+ "editor.tabSize" : 2
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ {
2+ "version" : " 2.0.0" ,
3+ "tasks" : [
4+ {
5+ "label" : " Terraform: Format" ,
6+ "type" : " shell" ,
7+ "command" : " terraform" ,
8+ "args" : [
9+ " fmt" ,
10+ " -recursive"
11+ ],
12+ "group" : " build" ,
13+ "presentation" : {
14+ "echo" : true ,
15+ "reveal" : " always" ,
16+ "focus" : false ,
17+ "panel" : " shared"
18+ },
19+ "problemMatcher" : []
20+ },
21+ {
22+ "label" : " Terraform: Validate" ,
23+ "type" : " shell" ,
24+ "command" : " terraform" ,
25+ "args" : [
26+ " validate"
27+ ],
28+ "group" : " test" ,
29+ "presentation" : {
30+ "echo" : true ,
31+ "reveal" : " always" ,
32+ "focus" : false ,
33+ "panel" : " shared"
34+ },
35+ "dependsOn" : " Terraform: Init (no backend)"
36+ },
37+ {
38+ "label" : " Terraform: Init (no backend)" ,
39+ "type" : " shell" ,
40+ "command" : " terraform" ,
41+ "args" : [
42+ " init" ,
43+ " -backend=false"
44+ ],
45+ "group" : " build" ,
46+ "presentation" : {
47+ "echo" : true ,
48+ "reveal" : " silent" ,
49+ "focus" : false ,
50+ "panel" : " shared"
51+ },
52+ "problemMatcher" : []
53+ },
54+ {
55+ "label" : " TFLint: Initialize" ,
56+ "type" : " shell" ,
57+ "command" : " tflint" ,
58+ "args" : [
59+ " --init"
60+ ],
61+ "group" : " build" ,
62+ "presentation" : {
63+ "echo" : true ,
64+ "reveal" : " silent" ,
65+ "focus" : false ,
66+ "panel" : " shared"
67+ },
68+ "problemMatcher" : []
69+ },
70+ {
71+ "label" : " TFLint: Run" ,
72+ "type" : " shell" ,
73+ "command" : " tflint" ,
74+ "args" : [
75+ " --format" ,
76+ " compact"
77+ ],
78+ "group" : " test" ,
79+ "presentation" : {
80+ "echo" : true ,
81+ "reveal" : " always" ,
82+ "focus" : false ,
83+ "panel" : " shared"
84+ },
85+ "dependsOn" : " TFLint: Initialize" ,
86+ "problemMatcher" : [
87+ {
88+ "owner" : " tflint" ,
89+ "fileLocation" : " relative" ,
90+ "pattern" : {
91+ "regexp" : " ^([^:]+):(\\ d+):(\\ d+):\\ s+(Error|Warning|Notice):\\ s+(.*)$" ,
92+ "file" : 1 ,
93+ "line" : 2 ,
94+ "column" : 3 ,
95+ "severity" : 4 ,
96+ "message" : 5
97+ }
98+ }
99+ ]
100+ },
101+ {
102+ "label" : " Terraform: Full Lint Check" ,
103+ "dependsOrder" : " sequence" ,
104+ "dependsOn" : [
105+ " Terraform: Format" ,
106+ " Terraform: Validate" ,
107+ " TFLint: Run"
108+ ],
109+ "group" : {
110+ "kind" : " test" ,
111+ "isDefault" : true
112+ },
113+ "presentation" : {
114+ "echo" : true ,
115+ "reveal" : " always" ,
116+ "focus" : false ,
117+ "panel" : " shared"
118+ }
119+ }
120+ ]
121+ }
You can’t perform that action at this time.
0 commit comments