Created
April 24, 2020 18:35
-
-
Save myoung34/7d4bd98e1bfab9c1bdd643fafd4d6174 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package terraform.analysis | |
import input as tfplan | |
resource_types = {"aws_db_instance"} | |
minimum_tags = min_created_tags { | |
some resource_type | |
min_created_tags := created_tags[resource_type] | |
} | |
contains(arr, i) { | |
arr[_] = i | |
} | |
tags_contain_proper_keys(tags) = true { | |
contains(tags, "environment") | |
contains(tags, "managed_by") | |
contains(tags, "team") | |
} else = false { true } | |
created_tags[resource_type] = num { | |
some resource_type | |
resource_types[resource_type] | |
all := resources[resource_type] | |
create_resources := [res | res:= all[_]; res.change.actions[_] == "create"] | |
tag_changeset := [res | res := [key | create_resources[_].change.after.tags[key]]] | |
num := tags_contain_proper_keys(tag_changeset[_]) | |
} | |
resources[resource_type] = all { | |
some resource_type | |
resource_types[resource_type] | |
all := [name | | |
name:= tfplan.resource_changes[_] | |
name.type == resource_type | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment