tfctl auth login
The tfctl auth login command authenticates with HCP Terraform or Terraform Enterprise.
Usage
$ tfctl auth login [options]
Description
The tfctl auth login command authenticates tfctl with HCP Terraform or Terraform Enterprise. The CLI stores your token in your active profile configuration and uses it for all API calls that require authentication.
When --token is specified, tfctl reads the token from standard input. Use this option for non-interactive environments such as CI/CD pipelines.
When --token is not specified, tfctl opens a browser to the token creation page for the configured hostname. Refer to Set hostname to learn how to set your hostname. The page prompts you to copy and paste the generated token.
Flags
--token: Read the token from standard input instead of prompting. When this flag is used, tfctl reads the token from stdin without opening a browser.- Optional.
- Data type: boolean
- Default value:
false
Global flags
Refer to Global flags reference for information about flags you can use with all commands.
Examples
The following examples demonstrate how to authenticate with HCP Terraform using the tfctl auth login command.
Interactive login
The following example opens your browser to create a token, then prompts you to paste it.
$ tfctl auth login
Login with token from stdin
The following example reads the token from stdin without opening a browser or prompting for input. This is useful for CI/CD pipelines and other non-interactive environments. Replace <MY_TOKEN> with your HCP Terraform or Terraform Enterprise API token.
$ echo <MY_TOKEN> | tfctl auth login --token