【发布时间】:2020-01-01 18:04:35
【问题描述】:
我正在尝试在 Terraform 中使用 local-exec 命令运行 shell 脚本。当我运行它时,它不断出现错误"Can't open appsettings.sh"。此脚本在手动运行时运行良好。有什么我想念的想法吗?
resource "null_resource" "sp" {
triggers = {
shell_hash = "${sha256(file("${path.module}/appsettings.sh"))}"
}
provisioner "local-exec" {
command = "appsettings.sh ${azuread_application.rbac-server-principal.application_id} ${azuread_application.rbac-client-principal.application_id}"
interpreter = ["sh"]
working_dir = "${path.module}"
}
}
错误信息:
Error: Error running command 'appsettings.sh 59942507-xxxx-xxxx-xxxxx 4c64-xxxx-xxxx-xxxxx': exit status 127. Output: sh: 0: Can't open appsettings.sh 59942507-xxxx-xxxx-xxxxx 4c64-xxxx-xxxx-xxxxx'
【问题讨论】:
-
不是权限问题??
-
我不这么认为,这只是在我的本地台式机上运行,所有文件都是本地的
-
今天上班碰巧有一个类似的案例,用ide和终端得到的结果不一样,确实是权限不一样的问题,我用你的代码状态在网上搜索了这个理由,没有成功, 但我得到的唯一结果是你的文件可能需要从 Linux 转换为 Linux ..
https://github.com/hashicorp/terraform/issues/5821 -
它看起来像是命令,如果我在提示符下运行相同的 sh 命令,则会收到此错误。如果我调整引号,我可以让它在本地运行,但在 Terraform 中还没有运气
标签: bash azure shell terraform