Having some issues when trying to run Powershell commands through a null-resource 'local-exec". I’m tryin trying to run a PowerShell command with some additional parameters:
provisioner “local-exec” {
interpreter = [“PowerShell”, “-Command”]
command = <<EOT
ResourceGroupName = '"{module.rg.resource_group.name}"’
FunctionAppName = '"{var.functionapp.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
}
Only when I hardcode the values the Az command executes.