This is the main.tf section
data "external" "extDateTime" {program = ["Powershell.exe", "${path.module}/getDateTime.ps1"] }
output "value" {value = "${data.external.extDateTime.result.dateTime}" }
This is the Powershell file getDateTime.ps1 code section
$DateTime = Get-Date -Format "yyyyMMddHHmmss"
`Write-Output "{""dateTime"": $DateTime}"`
Then I run the following command: terraform plan
Error: Unexpected External Program Results with data.external.extDateTime, on main.tf line 26, in data "external" "extDateTime": 26: program = ["Powershell.exe", "${path.module}/getDateTime.ps1"] The data source received unexpected results after executing the program. Program output must be a JSON encoded map of string keys and string values. Program: C:\WINDOWS\System32\WindowsPowerShell\v1.0\Powershell.exe Result Error: invalid character '{' after top-level value
My understanding is the PS script has to return in JSON format but I keep getting the Result Error. Any ideas would be appreciated.