File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ import "tfplan"
2
+
3
+ # Warning, this is case sensitive.
4
+ # This is on purpose especially for organizations that do cost analysis on tag names.
5
+ # where case sensitivity will cause grouping issues
6
+
7
+ mandatory_tags = [
8
+ "TTL",
9
+ "Owner",
10
+ ]
11
+
12
+ # Get all AWS instances contained in all modules being used
13
+ get_aws_instances = func() {
14
+ instances = []
15
+ for tfplan.module_paths as path {
16
+ instances += values(tfplan.module(path).resources.aws_instance) else []
17
+ }
18
+ return instances
19
+ }
20
+
21
+ aws_instances = get_aws_instances()
22
+
23
+ # Instance tag rule
24
+ instance_tags = rule {
25
+ all aws_instances as _, instances {
26
+ all instances as index, r {
27
+ all mandatory_tags as t {
28
+ r.applied.tags contains t
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ main = rule {
35
+ (instance_tags) else true
36
+ }
You can’t perform that action at this time.
0 commit comments