试图理解 OPA 中虚假的概念。我的情况是这样的——我需要验证所有云资源是否都在 AWS 的允许区域内。我现在拥有的是:
allowed_locations := ["eastus", "westus"]
exists(array, value) {
array[_] == value
}
all_resources_in_allowed_regions {
not any_resource_not_in_allowed_regions
}
any_resource_not_in_allowed_regions {
some index
exists(allowed_locations, input.planned_values.root_module.resources[index].values.location) != true
}
问题是,我认为当策略/函数的结果不正确时,我会遗漏一些东西 - 例如,结果exists(allowed_locations, "westeurope")
不是假的,而是某种“未定义”,这意味着结果exists(allowed_locations, "westeurope") != true
也是“未定义” ",这意味着分配了 all_resources_in_allowed_regions,not "undefined"
这是真的。
您将如何使用 OPA 解决此问题?我是否缺少有关正确使用它的方法?