3

Is it possible to compile a Terraform script into an ARM template?

I assume this should be somehow possible, since I think Terraform is internally doing exactly this, when deploying IaaS to Azure.

Codo
  • 75,595
  • 17
  • 168
  • 206
eztam
  • 3,443
  • 7
  • 36
  • 54
  • 4
    The *arm* tag refers to the ARM microprocessor architecture. I've replaced it with the tag for *Azure Resource Manager* – Codo Sep 10 '20 at 09:22

2 Answers2

6

You can export the ARM templates from Azure portal after deploying resources with Terraform.

I don't know if a tool exists to do this more elegantly.

enter image description here

adp
  • 1,191
  • 2
  • 8
  • 23
  • thats a nice catch, but bear in mind some resources might not get exported entirely and some might not get exported at all, and the resulting arm templates are of extremely low quality and need lots of refinement, I'd probably go with reworking initial TF code, its less work :( – 4c74356b41 Sep 11 '20 at 06:41
4

I dont think there is an easy way of doing that (i.e. there is no tool capable of doing that), but you can capture REST requests terraform is doing against Azure API, they would closely match what an ARM Template does, however you would still require a lot of manual editing, because ARM Templates have their own structure, their own syntax etc.

An alternative - would be to just rewrite it, terraform syntax is pretty much a copy of what arm templates look like (apart from the way operators are implemented and so on and so fourth)

4c74356b41
  • 69,186
  • 6
  • 100
  • 141