Procedure to automate terraform commands

Hi,

I have just started on terraform.

I can run terraform init, terraform plan, apply etc within the directory where main.tf resides. I can automate all these by creating a bash command to execute and log the output. Is this a correct approach?

Thanks

From what I’ve seen, I won’t say it’s a correct approach, but a working one.

The correct approach would be to store the codebase in git and run the Terraform plan / apply from the CI, it’s more streamlined.

Many thanks.

Shall I follow the procedures outlined here. I have terraform installed on-premise already.

Hi @michTalebzadeh,

That guide could be useful if you intend to automate Terraform with GitHub Actions in particular.

The following is a more general guide that describes how you can use Terraform’s commands in an automation-friendly way regardless of exactly what automation solution you are using:

Since this is a more general guide it isn’t quite as prescriptive as the GitHub Actions guide, but it will hopefully give you a small set of options to consider as you write your automation script.

Many thanks @apparentlymart I will have look

Regards