REGO - Denying MX record and eval to true for AAA and CNAME
package example
import future.keywords.every
default allow_update := false
allow_update {
resource := input[_]
dns_update := resource["ngine_io.vultr.vultr_dns_record"]
dns_update.record_type == "CNAME"
}
allow_update {
resource := input[_]
dns_update := resource["ngine_io.vultr.vultr_dns_record"]
dns_update.record_type == "AAA"
}
# deny MX Records from being updated
deny[msg] {
resource := input[_]
dns_record := resource["ngine_io.vultr.vultr_dns_record"]
dns_record.record_type == "MX"
msg := sprintf("dns_record '%v' Our policy recommends no changes to MX records", [dns_record])
}
INPUT file .
[
{
"name": "Ensure an A record exists",
"ngine_io.vultr.vultr_dns_record": {
"name": "www",
"domain": "example.com",
"data": "10.10.10.10",
"ttl": 3600
}
},
{
"name": "Ensure a second A record exists for round robin LB",
"ngine_io.vultr.vultr_dns_record": {
"name": "www",
"domain": "example.com",
"data": "10.10.10.11",
"ttl": 60,
"multiple": true
}
},
{
"name": "Ensure a CNAME record exists",
"ngine_io.vultr.vultr_dns_record": {
"name": "web",
"record_type": "CNAME",
"domain": "example.com",
"data": "www.example.com"
}
},
{
"name": "Ensure a CNAME record exists",
"ngine_io.vultr.vultr_dns_record": {
"name": "web",
"record_type": "AAA",
"domain": "example.com",
"data": "www.example.com"
}
},
{
"name": "Ensure a CNAME record exists",
"ngine_io.vultr.vultr_dns_record": {
"name": "web",
"record_type": "MX",
"domain": "example.com",
"data": "www.example.com"
}
}
]
Comments
Post a Comment