terraform/website/source/intro/getting-started/remote.html.markdown

2.7 KiB

layout page_title sidebar_current description
intro Terraform Remote gettingstarted-remote We've now seen how to build, change, and destroy infrastructure from a local machine. However, you can use Atlas by HashiCorp to run Terraform remotely to version and audit the history of your infrastructure.

Why Use Terraform Remotely?

We've now seen how to build, change, and destroy infrastructure from a local machine. This is great for testing and development, however in production environments it is more responsible to run Terraform remotely and store a master Terraform state remotely. Otherwise it's possible for multiple different Terraform states to be stored on developer machines, which could lead to conflicts. Additionally by running Terraform remotely, you can move access credentials off of developer machines, release local machines from long-running Terraform processes, and store a history of infrastructure changes to help with auditing and collaboration.

How to Use Terraform Remotely

Using Terraform remotely is straightforward with Atlas by HashiCorp. You first need to configure Terraform remote state storage with the command:

$ terraform remote config -backend-config="name=ATLAS_USERNAME/getting-started"

Replace ATLAS_USERNAME with your Atlas username. If you don't have one, you can create an account here.

Next, push your Terraform configuration to Atlas with:

$ terraform push -name="ATLAS_USERNAME/getting-started"

This will automatically trigger a terraform plan, which you can review in the Environments tab in Atlas. If the plan looks correct, hit "Confirm & Apply" to execute the infrastructure changes.

Version Control for Infrastructure

Running Terraform in Atlas creates a complete history of infrastructure changes, a sort of version control for infrastructure. Similar to application version control systems such as Git or Subversion, this makes changes to infrastructure an auditable, repeatable, and collaborative process. With so much relying on the stability of your infrastructure, version control is a responsible choice for minimizing downtime.

Next

You now know how to create, modify, destroy, version, and collaborate on infrastructure. With these building blocks, you can effectively experiment with any part of Terraform.

Next, we move on to features that make Terraform configurations slightly more useful: variables, resource dependencies, provisioning, and more.