{
  "apiVersion": "json.kyverno.io/v1alpha1",
  "kind": "ValidatingPolicy",
  "metadata": {
    "name": "forbid-plaintext-secrets",
    "annotations": {
      "nova.cloudinit.dev/severity": "high",
      "title.policy.kyverno.io": "No plaintext secrets in the terraform plan"
    }
  },
  "spec": {
    "rules": [
      {
        "name": "no-plaintext-db-password",
        "assert": {
          "all": [
            {
              "check": {
                "planned_values": {
                  "root_module": {
                    "~.resources": {
                      "(type == 'aws_db_instance' && contains(keys(values), 'password') && !contains(['${...}', ''], values.password))": false
                    }
                  }
                }
              }
            }
          ]
        }
      }
    ]
  }
}