Virtual Event
Join us for the next HashiConf Digital October 12-15, 2020 Register for Free

Collaborate using Terraform Cloud

Authenticate the CLI with Terraform Cloud

Terraform Cloud can run Terraform configuration and store state remotely, allowing you to use Terraform without worrying about the stability of your local machine.

You can interact with Terraform Cloud using the Terraform CLI by logging in. Logging in allows you to trigger remote plans and runs, migrate state to the cloud, and perform other remote operations on configurations that includes Terraform Cloud as a remote back end.


»Start the login flow

In order to authenticate with Terraform Cloud, run the terraform login subcommand. Terraform will prompt you to confirm that you want to authenticate by typing y in your terminal.

$ terraform login
Terraform will request an API token for using your browser.

If login is successful, Terraform will store the token in plain text in
the following file for use by subsequent commands:

Do you want to proceed? (y/n)

»Generate a token

A browser window will automatically open to the Terraform Cloud login screen. Enter a token name in the web UI, or leave the default name, "terraform login".

Modal window in Terraform Cloud titled "Create API token". There is a text box to set a name for the token.

Click "Create API token" and Terraform Cloud will generate the authentication token.

Modal window in Terraform Cloud titled "Create API token". The window contains a token value.

Save a copy of the token in a secure location. It provides access to your Terraform Cloud organization.

»Add the token to the CLI

Your terminal will prompt you for the generated user token.

Terraform must now open a web browser to the tokens page for

If a browser does not open this automatically, open the following URL to proceed:


Generate a token using your browser, and copy-paste it into this prompt.

Terraform will store the token in plain text in the following file
for use by subsequent commands:

Token for

Paste the user token exactly once into your terminal. Terraform will hide the token for security, so when you paste it in you will not see it. Press Enter and you will now have access to the Terraform Cloud backend.

Retrieved token for user terraform_user


Success! Terraform has obtained and saved an API token.

The new API token will be used for any future Terraform command that must make
authenticated requests to

»Next Steps

Once you have authenticated to Terraform Cloud, you're ready to Perform remote operations. Continue to the next guide to migrate a state file to Terraform Cloud.

Discover more remote operations to perform with a logged in CLI in the Terraform Cloud CLI-driven Runs documentation.