在制定terraform政策时使用哨兵进口

时间:2018-02-09 15:42:07

标签: devops sentinel devops-services devops-insights

嘿我正在尝试使用terraform的sentinel cli我有一个policy.sentinel文件

import "tfplan"
allowed_machine_types = [
    "n1-standard-1",
    "n1-standard-2",
    "n1-standard-4",
    "n1-standard-8",
]

main = rule {
    all tfplan.resources as type, resources {
        all resources as r {
            r.applied.machine_type in allowed_machine_types
        }
    }
}

和我的导入的config.json文件

{
"imports":{
    "tfplan": {
        "path": "./plan"
        }
    }
}

该计划是运行

后生成的可执行文件
terraform plan -out plan

当我运行sentinel apply -config=config.json policy.sentinel

我的错误

Runtime error while running the policy:

test.sentinel:1:1: fork/exec ./plan: exec format error

A runtime error is a non-recoverable error and always represents a bug
in the policy. When a runtime error is experienced, the result of the
policy is "false". Please fix the error above and try again.

我不是很擅长哨兵所以可能会有什么问题?我们如何使用进口?我试过通过文档,我无法得到如何去做它

1 个答案:

答案 0 :(得分:1)

您无法执行计划文件,因为它不可执行 - 您需要执行terraform计划插件:在任何地方都无法使用..