Just wondering if terraform init
is compulsory before every terraform plan
?
i.e. if I've already done a terraform init
but are about to do a second terraform plan
based on some changed Terraform code would you need to do a second terraform init
?
It depends.
Depending on exactly what the Terraform code is you've changed, you may need to re-run init. For instance, if you've made changes to a configured backend, you'll need to rerun terraform init
to re-initialise with those changes. If the changes are to non-terraform configuration parts of your script, terraform plan
and terraform apply
should be fine to use by themselves.
One further note is that if you're using modules, and you make a change in a module, you will need to re-run terraform get -update
to get those changes before running plan
or apply
.
Agree with all the above answers, but something to add here is that it is safe to run terraform init many times even if nothing changed, its not going to affect anything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With