【问题标题】:using sentinel imports while making policies in terraform在 terraform 中制定策略时使用哨兵导入
【发布时间】:2018-12-17 00:37:19
【问题描述】:

嘿,我正在尝试使用带有 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.

我不是很擅长哨兵,所以可能有什么问题?我们如何使用进口?我尝试浏览文档,但我不知道该怎么做

【问题讨论】:

    标签: devops sentinel devops-services devops-insights


    【解决方案1】:

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

    【讨论】:

    • 那么使用 terraform 和 sentinel CLI 的替代方法是什么
    • 在我看来你不能 - 除非你使用 terraform enterprise
    猜你喜欢
    • 1970-01-01
    • 2021-04-22
    • 1970-01-01
    • 1970-01-01
    • 2014-10-11
    • 1970-01-01
    • 1970-01-01
    • 2022-01-04
    • 1970-01-01
    相关资源
    最近更新 更多