Bicep vs Terraform and modifying resources

Johan Furu 26 Reputation points
2022-10-19T09:20:31.293+00:00

I'm trying to get my head around the differences to how Bicep and Terraform handles modifications of resources previously deployed. My goal is to be able to maintain the configuration by running the same deployment file over and over to prevent drift but also later modifying an initial configuration.

With Bicep you can run a CLI deployment command with what-if and get an output of what the deployment would do, resources to be added, modified and removed. With Terraform you have the state file and Terraform apply will get you the same output of resources to be added, modified and removed. So this tells me that both methods get the same result but with different techniques.

My question is, are there any real differences to how these two deployment languages deal with modifications and is there an advantage with one or the other?

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
38,769 questions
0 comments No comments
{count} vote

Accepted answer
  1. Sam Cogan 10,502 Reputation points MVP
    2022-10-19T09:29:00.95+00:00

    The big difference between Bicep and Terraform in this area is state. Bicep takes it's state directly from Azure, Terraform maintains a state file which it uses as it's source of truth. By default when you run Terraform Plan or Apply it will also run a refresh command against the infrastructure in Azure to compare it to the state in Azure and modify the state file if needed.

    So, given that, generally you should get the same result from Bicep's What-If and Terraform Plan, but it might not be exactly the same for a few reasons:

    1. Terraform's preview is a lot more mature than the what-if command, it's been around longer and they have weeded out a lot of the issues around displaying changes that actualy are just platform data that you have no control over.
    2. If you force Terraform to not do a refresh then it will only look at the state file, which may differ from what is in Azure

    So if your purely looking at being able to do what-if/plan type comparisons then either language would proabably do what you want. Personally I find the Terraform plan experience a bit nicer than the what-if one, but that's personal preference.

    That said, I wouldn't be making a decision to use Terraform or not purely based on that. Terraform has many other features that may be useful to you. The biggest one being the ability to deploy non-azure resources, so if your looking to do cross-cloud deployments this is important. Another feature is the ability to destroy resources, because Terraform tracks everything in it's state file it can destroy what it created, Bicep/ARM can't do that. So it really depends what you want your IaC tool to do.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.