【发布时间】:2022-01-19 18:39:20
【问题描述】:
尝试通过空资源“local-exec”运行 Powershell 命令时遇到一些问题。我正在尝试运行带有一些附加参数的 PowerShell 命令:
provisioner “local-exec” {
interpreter = [“PowerShell”, “-Command”]
command = <<EOT
$ResourceGroupName = '"${module.rg.resource_group.name}"'
$FunctionAppName = '"${var.function_apps[each.key].name}"'
$SubscriptionId = '"${var.subscriptions.id}"'
# Option 1 - does nothing
Get-AzFunctionApp -ResourceGroupName $ResourceGroupName -Name $FunctionAppName -SubscriptionId $SubscriptionId
# Option 2 - does nothing
(Get-AzFunctionApp -ResourceGroupName $ResourceGroupName -Name $FunctionAppName -SubscriptionId $SubscriptionId)
# Option 3 - shows the correct cmd line with correctly expanded variables but does not execute the command
"Get-AzFunctionApp -ResourceGroupName $ResourceGroupName -Name $FunctionAppName -SubscriptionId $SubscriptionId"
# Option 4 - when I hardcode the values it works
Get-AzFunctionApp -ResourceGroupName "real_rg_name" -Name "real_rg_appname" -SubscriptionId real_subscr_id
EOT
}
仅当我对 Az 命令执行的值进行硬编码时。
【问题讨论】:
标签: terraform azure-powershell