REGO - Code for DNS update :Deny MX update

 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 

==The below is working

package example

import future.keywords.every

#default allow_update := false

#allow_update {
#  resource := input[_]
#  dns_record := resource["ngine_io.vultr.vultr_dns_record"]
#  dns_record.record_type == "CNAME"
# }

deny[msg] {  
    resource := input[_]
    dns_record := resource["ngine_io.vultr.vultr_dns_record"]
    dns_record.record_type == "MX"                               
    msg := sprintf("dns_record '%v' No change is recommended for 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

Popular posts from this blog

Sty -OPA - Rego : What is OPA

Sty -OPA - Rego : Comparing and Constructing Values

Sty -OPA - Rego : Basic Rego Rules