Special Commands
So far, you have read about the core Terraform workflow commands and then followed this up with the code reformatting commands that will be used in most cases. In this section, you will see some special commands in appropriate scenarios.
The login Command
The terraform login
command is used to obtain and save an API token for HCP Terraform, Terraform Enterprise, or any other compatible host. In the case of HCP Terraform and Terraform Enterprise, the user will be interacting with the host with the API token as the authentication mechanism and it is applicable to use in interactive scenarios.
This is how the command is used:
$ terraform login <HOSTNAME>
In case HOSTNAME
is not specified, it will default to the HCP Terraform host at app.terraform.io
.
If the command execution is successful in CLI, the API token retrieved will be stored locally in the file named credentials.tfrc.json
by default. But there is also an option to change this behavior...