Now that you have provisioned infrastructure with Terraform Cloud, you are ready to make changes to that infrastructure.
Terraform Cloud offers multiple ways to set variable values for your configuration. In the previous tutorial, you defined your variables in the web UI. Now, you will use per-run variables passed on the command line to modify your EC2 instance configuration.
The landing page for a workspace includes an overview of its current state and configuration.
On the upper right side find:
- The resource count for the workspace.
- the Terraform version used for the workspace.
- the time since the last update.
- the lock icon indicating whether the workspace is locked, which prevents others from triggering new runs.
- the Actions drop down, which allows you to lock the workspace or trigger a new run.
The rest of the page shows details about the most recent run and current settings for your workspace.
- The Latest run section displays details of the last run, including a count of resource modifications, duration, and estimated change in cost.
- The resources and outputs tables display details about the current infrastructure and any outputs defined for the workspace.
- The sidebar contains metrics and details about workspace settings. It also includes a section for workspace tags. You can manage your workspace's tags here, and your list of tags in your Organization settings. Tags allow you to group and filter your workspaces.
The workspace's menu lists available actions and configurations for the workspace.
- The Runs page lists all of the plan and apply actions you have taken with this workspace.
- The States page lists the state files for all successful past runs in the workspace. Terraform records data about your resources as a
tfstatefile. The state file is central to Terraform operations, and Terraform uses it to determine which changes to make to your resources over their lifecycle.
- The Variables page lists the Terraform variables, environment variables, and variable sets configured for the workspace.
- The Settings page contains all of the Terraform Cloud settings for your workspace, and is where you will destroy your infrastructure at the end of these tutorials.
Navigate to the the Runs page, and notice the run attributes that you can filter the list of runs by.
- Status lets you filter by the stage of the run, such as
- Operation lets you filter by the run type, such as
- Source lets you filter by the run workflow,
Use variables to make your configuration flexible enough to use in different contexts. Setting variable values is one of the most common ways to customize Terraform configuration, and Terraform Cloud supports multiple ways to manage variables.
Like with open source Terraform, you can pass per-run variables to Terraform
Cloud using command line flags. When using the CLI-driven workflow for
Terraform Cloud, any variables passed using the
-var flag will override
workspace-specific variables. However, Terraform Cloud will not save the new
value in your workspace unless you update the variable in the UI. This feature
can be useful when you want to test or temporarily apply a change that you
expect to revert on the next apply, so your stored variable values continue to
reflect the desired eventual configuration.
In your terminal, start a new Terraform run for your workspace. Use a command line variable to update the instance type for your EC2 instance to
$ terraform apply -var="instance_type=t2.small" Running apply in Terraform Cloud. Output will stream here. Pressing Ctrl-C will cancel the remote apply if it's still pending. If the apply started it will stop streaming the logs, but will not stop the apply running remotely. Preparing the remote apply... To view this run in a browser, visit: https://app.terraform.io/app/hashicorp-training/learn-terraform-cloud/runs/run-zRZTVvucaBrQMnjD ##...
Once again, Terraform will trigger a run in your
workspace and stream the output to your terminal. You can also review the
details for the run in the workspace itself.
The Terraform AWS provider determined that it can modify your instance type in place. Approve the run to resize your EC2 instance.
Review the documentation on variables in Terraform Cloud to learn more about variable precedence in a workspace.
In these tutorials, you created a Terraform Cloud account and organization, authenticated from the command line, created a Terraform Cloud workspace, and used the CLI-driven workflow to create and modify infrastructure.
In the next tutorial, you will update your workspace settings to instead use the VCS-driven workflow and trigger Terraform operations off of pull requests.