April 6 & 7
Learn about Vault, Consul, & more at HashiDays Sydney in Australia Register Now

Getting Started - Terraform Cloud

Apply Configuration Changes

You have now seen how to add a new Workspace to Terraform Cloud. In this guide, you will apply some changes to your configuration. Before we do that, we will explore the Workspace UI to understand how Terraform Cloud manages Workspaces.

  1. Explore Your Workspace
  2. Changing Variables
  3. Changing Configuration

Explore your workspace

Within the Terraform Cloud UI, you will notice several menus and options for your Workspace, including Runs, States, Variables, Settings, and the Queue plan interface you used to apply the example configuration.

Workspace Actions

  • Under "Runs", you will find a list of all of the plan/apply actions you have taken with this workspace
  • "States" shows a list of the state of your Workspace after each successful run, including the entire tfstate file
  • "Variables", as you have already seen, will let you configure Terraform Variables and Environment Variables
  • "Settings" contains all of the other configuration for your Workspace.
  • "Queue plan" is an interface to start a new plan

Before you continue, you may wish to explore the Workspace interface further.

Since there haven't been any changes since the last successful run, you can safely queue a new plan, and you will see that there were no changes to apply.

There are two main things that could introduce a change that will need to be applied. First, a change to one or more variables will usually require a change in your configuration. Second, a change to the underlying configuration, such as a commit to your GitHub repository, will probably trigger a new run to apply those changes. We will look at both of those scenarios in turn.

Changing variables

In the Terraform Cloud interface, return to the "Variables" section of your Workspace.

First, change the value of db_read_capacity from 2 to 1 and click the purple "Save variable" button. Then use the "Queue plan" interface to begin another run. After a few seconds, the plan will be complete, and in the plan log, you should see Plan: 0 to add, 1 to change, 0 to destroy.

Plan Finished

In this case, Terraform can make the change to the DynamoDB table without destroying and recreating it. Click the "Confirm & Apply" button, followed by the "Apply Change" button to apply the change.

Changing configuration

In addition to changes to your variables, another way in which your configuration will change is through changes to the configuration files themselves. In this guide, we will update your configuration by using a GitHub Pull Request.

First, you'll need to visit your fork of the tfc-guide-example project in GitHub. From there, use the "New pull request" interface to create a pull request. Set the base branch to be the master branch of your fork, and the compare branch to be the add-username one.

Pull Request

Once you have created the pull request, Terraform Cloud will trigger a speculative plan. Visit your workspace in the Terraform Cloud UI, and click on the "Runs" tab. You will see that a new run was created, and you can review the plan before merging the pull request. This is another way that teams can collaborate on changes to their Terraform configuration before they are implemented.

Speculative plans cannot be applied. You will need to merge the pull request before applying this change.

Return to the GitHub UI, and merge the pull request with the "Merge pull request" button.

Switch back to the "Runs" tab for your workspace in Terraform Cloud. You will see that Terraform Cloud picked up the change to your configuration and has started a new run.

Run Triggered by Pull Request

Click on the new run in the Terraform Cloud UI, and you'll see the run details. Just as before, you can "Confirm & Apply" the run.

Now that you've experienced the process of configuring a new Workspace, and applying changes to your configuration with Terraform Cloud. In the next guide, we will clean up the resources created by your configuration, and look at next steps.