Skip to content

Commit 18e81d9

Browse files
committed
added terraform version policy
1 parent e7f71eb commit 18e81d9

File tree

5 files changed

+1036
-0
lines changed

5 files changed

+1036
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#The policy uses the tfplan import to enforce the usage of Terraform version 0.12 or higher
2+
3+
import "tfplan/v2" as tfplan
4+
5+
#Minimum allowed version variable
6+
min_allowed_version = "0.12.0"
7+
violations = 0
8+
9+
#Condition to check version
10+
if (tfplan.terraform_version < min_allowed_version) {
11+
violations = 1
12+
print("You are using terraform version", tfplan.terraform_version, "which is outdated.Please use any version higher than or equal to", min_allowed_version)
13+
}
14+
15+
#Main rule
16+
main = rule {
17+
violations is 0
18+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"mock": {
3+
"tfplan/v2": "mock-tfplan-fail.sentinel"
4+
},
5+
"test": {
6+
"main": false
7+
}
8+
}

0 commit comments

Comments
 (0)