【发布时间】:2020-11-06 00:24:29
【问题描述】:
我目前正在运行一些 Terraform 以在 Azure 中创建资源。我们已经编写了一个模块来创建一个包含一堆变量的资源组。提供商目前不允许创建预算和成本警报,但 Powershell 模块可以。我想我们可以添加一个 Powershell 脚本来执行设置。我似乎遇到了一个障碍,我无法完全弄清楚如何处理 Powershell 脚本。我有以下内容:
resource "null_resource" "PowerShellScriptRunAlways" {
triggers = {
always_run = "${timestamp()}"
}
provisioner "local-exec" {
command = ".'${path.module}//pwsh//costalert.ps1 -subscriptionID \"${var.azure_subscription_id}\" -tenantID \"${var.azure_tenant_id}\" -clientID \"${var.azure_client_id}\" -clientSecret \"${var.azure_client_secret}\" -budgetAmount \"${var.budgetAmount}\" -rgName \"${azurerm_resource_group.this.name}\" -emailAddresses \"${var.emailAddresses}\"'"
interpreter = ["pwsh", "-Command"]
}
}
使用 pwsh,因为它在 Linux Jenkins 代理上运行。这是 ps1 文件位于“根模块目录/pwsh”下的模块的一部分,但它似乎产生以下内容:
Error: Error running command '.'.terraform/modules/rg_test\pwsh\costalert.ps1 -subscriptionID "xxxxx" -tenantID "xxxxxxx" -clientID "xxxxxx" -clientSecret "xxxxx" -budgetAmount "1000" -rgName "rg-da_test-sbxeng-001" -emailAddresses "xxxxxx"'': exit status 1. Output: . : The module '.terraform/modules/rg_test' could not be loaded. For more information, run 'Import-Module .terraform/modules/rg_test
+ .'.terraform/modules/rg_test\pwsh\costalert.ps1 -subscriptionID
它似乎正在切换路径,但似乎无法让它拾取脚本并运行它。有人有什么建议吗?
【问题讨论】:
标签: linux powershell terraform