Skip to content

Commit 7d0147b

Browse files
committed
feat: add conftest policy for provider version pinning in modules
1 parent cae60ba commit 7d0147b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package main
2+
3+
import rego.v1
4+
5+
deny_unpinned_provider_version contains msg if {
6+
some path
7+
some block in input.resource.terraform[path]
8+
some name, provider in block.required_providers
9+
version_constraint := object.get(provider, "version", "")
10+
version_constraint != ""
11+
not contains(version_constraint, "~>")
12+
not contains(version_constraint, "=")
13+
endswith(version_constraint, ".x")
14+
msg := sprintf(
15+
"%s/versions.tf: provider '%s' has loose version constraint '%s' - pin to specific version or use '~>' for minor version pinning",
16+
[path, name, version_constraint],
17+
)
18+
}

0 commit comments

Comments
 (0)