Terraform basic commands
In this section, we will learn some basic Terraform commands that are often used when writing code. We will also examine concepts that are relevant to Terraform.
The init command
Every time we start writing Terraform code, the first command that we run is terraform init
. This command prepares all the necessary dependencies required to run the code locally. The command performs the following steps:
- Downloads all the necessary modules that are used in the code.
- Initializes plugins that are used in the code. For example, if the code is deployed on AWS it will download the AWS plugins.
- Creates a file called a lock file that registers the different dependencies and versions that are used by the code.
To gain a better understanding of the previous steps, let’s run the command. Open the terminal and change to the chapter14/simple
directory, and execute the following command:
terraform init
You will see an output as follows...