# Terraform Cloud

* Terraform Cloud allows teams to easily version, audit, and collaborate on infrastructure changes. It also securely stores variables, including API tokens and access keys, and provides a safe, stable environment for long-running Terraform processes.
*   Example of terraform cloud configuration.

    ```
    terraform {
        // Cloud configuration

        backend "remote" {
            organization = "my_organization"
            workspaces {
              name = "Example-Workspace"
            }
        }

        //Provider configuration
        required_providers {
            aws = {
            source  = "hashicorp/aws"
            version = "~> 3.27"
            }
        }
    }

    ```
* Sign up for terraform cloud account and create an organization.
* Use `terraform login` command to login to the cloud account from the terminal. This will open a browser with access token. Copy the access token and paste it into the input prompt. (Note, while pasting input will be hidden).
* Once above steps are done, run `terraform init` to reinitialize the configuration and migrate/store the state to terraform cloud.
* Once migration is completed, delete the local state file, if it exists.
* Set up access key and secret tokens for you cloud provider in you terraform cloud organization under `variables` tab.
* Once access keys are configured, run `terraform apply` to trigger a run in terraform cloud.
* Note: terraform state is only loaded to memory when a terraform run is triggered.
