Terraform output as PR comment in Azure DevOps

I encourage you to read my blog post in which I describe how to put terraform plan in a PR comment. By setting a branch policy, you can force the approval of the plan as a mandatory step before the merge. [A full description can be found at this link.]

Great blogpost, I created approximately the same. To improve your blog: for large bodies/big plan outputs I saw the request failing. Don’t know why, but circumvented it by writing the request JSON to file and use that:

$newThreadBody | Out-File ./body.json
$thread = Invoke-RestMethod -Uri $newThreadEndpoint -Headers $headers  -Method Post -InFile './body.json' -ContentType 'application/json'