How to output Terraform output file in Azure DevOps in release pipeline. I am using Run Terraform task in Release pipeline. I have a output file in Repo which outputs public IPs. I want to store it as Variable which can be used in further tasks.
1 Answers
3
votes
For this issue ,it can be done with a simple output and powershell script:
1.Specify the output variable from terraform task
2.Create a PowerShell step in your release and insert the following script:
$json = Get-Content $env:jsonPath | Out-String | ConvertFrom-Json
foreach($prop in $json.psobject.properties) {
Write-Host("##vso[task.setvariable variable=$($prop.Name);]$($prop.Value.value)")
}
This will automatically create a variable for every output provided by the terraform
script.
Make sure you have provided the environment variable jsonPath like this:
Here is the reference you can refer to.