Created
June 8, 2023 19:22
-
-
Save adamenger/6d09e5ab5dc0491e168b59e58cdfefb4 to your computer and use it in GitHub Desktop.
This file contains 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 spacelift | |
# Define the forbidden roles | |
forbidden_roles := {"editor", "owner"} | |
# Deny when creating or updating a google_project_iam_binding with forbidden roles | |
deny[sprintf("Resource '%s' has a forbidden role.", [resource.address])] { | |
# Select the resource from the input | |
resource := input.terraform.resource_changes[_] | |
# Check if the resource is a google_project_iam_binding and the action is either create or update | |
resource.type == "google_project_iam_binding" | |
resource.change.actions[_] == "create" | |
# Check if the role_key is in the set of forbidden roles | |
forbidden_roles[resource.index] | |
} | |
# Deny when creating or updating a google_project_iam_binding with forbidden roles | |
warn[sprintf("Resource '%s' has a forbidden role.", [resource.address])] { | |
# Select the resource from the input | |
resource := input.terraform.resource_changes[_] | |
# Check if the resource is a google_project_iam_binding and the action is either create or update | |
resource.type == "google_project_iam_binding" | |
resource.change.actions[_] == "update" | |
# Check if the role_key is in the set of forbidden roles | |
forbidden_roles[resource.index] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment