Terraform 云中的哨兵导入混淆:键"find_resources"不支持函数调用



我在Terraform Cloud工作空间中使用Sentinel策略。我的策略很简单:

import "tfplan/v2" as tfplan
allBDs = tfplan.find_resources("aci_bridge_domain")
violatingBDs = tfplan.filter_attribute_does_not_match_regex(allBDs,
"description", "^demo(.+)", true)                      

main = rule {
length(violatingBDs["messages"]) is 0
}

不幸的是,它在使用以下消息调用时失败:

An error occurred: 1 error occurred:
* ./allowed-terraform-version.sentinel:3:10: key "find_resources" doesn't support function calls

find_resources (doc)的文档和源代码期望一个字符串,然而Sentinel解释器似乎认为我正在调用tfplan?为什么会这样还不清楚,文档也没有什么帮助。

任何想法?

好的,我发现了问题。如果我粘贴find_resources及其依赖项(to_string, evaluate_attribute)的代码,那么一切都像预期的那样工作。

所以我有一个简单的导入问题,需要弄清楚如何正确导入https://raw.githubusercontent.com/hashicorp/terraform-guides/master/governance/third-generation/common-functions/tfplan-functions/tfplan-functions.sentinel

最新更新