Reputation: 1073
Trying to figure out the proper way to pass named arguments to my powershell script using terraform local-exec.
Do I need to quote delimit params in this case like so?
provisioner "local-exec" {
command = "powershell -file ../BindCert.ps1 -certString '${var.cert_string_b64}' -certPassword '${var.cert_password}' -certThumbprint '${var.cert_thumbprint}' -certName '${var.cert_name}'"
}
Windows 10 Powershell 5.1
Upvotes: 1
Views: 6189
Reputation: 31414
For your issue, you can change the code like below:
provisioner "local-exec" {
command = "powershell -file ../BindCert.ps1 -certString ${var.cert_string_b64} -certPassword ${var.cert_password} -certThumbprint ${var.cert_thumbprint} -certName ${var.cert_name}"
}
I will show you the test which I did on my side.
PowerShell script:
param([String]$rgName = "rgName")
Get-AzResourceGroup -Name $rgName
Terraform code:
variable "test" {
type = "string"
default = "charles"
}
resource "null_resource" "test" {
provisioner "local-exec" {
command = "PowerShell -file ./test.ps1 -rgName ${var.test}"
}
}
The screenshot of the result:
For more details, see Terraform local-exec Provisioner.
Upvotes: 3