Now that you have provisioned infrastructure with Terraform Cloud, you're ready to make changes to that infrastructure.
There are two ways to update your workspace deployments on Terraform Cloud — changing the configuration in VCS or updating variables in the Terraform Cloud UI.
In this tutorial you will change the read capacity of a DynamoDB table by adjusting a Terraform variable in the Terraform Cloud web UI. You will also add a user name attribute to the table by opening and then merging a pull request to your configuration repository.
»Explore your workspace
The landing page for a workspace includes an overview of its current state and configuration.
Along the top is a menu of available actions and configurations for the workspace.
- Runs shows a list of all of the plan and apply actions you have taken with this workspace.
- States shows the state of your workspace after each successful run. Terraform stores everything it knows about your infrastructure in state as a
tfstatefile. This allows Terraform to not only create — but also manage — your infrastructure as it changes over time.
- Variables is where you configure Terraform variables and environment variables.
- Settings contains all of the Terraform Cloud settings for your workspace, and is where you will destroy your infrastructure at the end of these tutorials.
- The lock icon allows you to lock the workspace, preventing anyone else from triggering runs.
- Queue plan queues manual plans and applies, which you did to create your infrastructure.
The workspace overview shows details about the most recent run and current settings for your workspace.
Latest run displays details of the last run, including a count of resource modifications, duration, and estimated change in cost.
Outputs display the values of any outputs defined in your Terraform configuration for easy access.
The sidebar contains metrics and details about workspace settings.
Scrolling further down, you'll find the
README for the repository, if one
Infrastructure-as-code allows you to share and recreate infrastructure. Variables make your configuration flexible enough to use in different contexts. Changing variables is one of the most common ways to customize or update infrastructure, and you can do it from the Terraform Cloud web UI.
In the Terraform Cloud UI, return to the "Variables" section of your workspace.
Change the value of
1 and click the purple "Save variable" button.
Use the "Queue plan" interface to begin another run. After the plan completes, the plan log should indicate that there are
0 to add, 1 to change, 0 to destroy.
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.
If you work on the team that maintains your infrastructure, you may need to develop your configuration by modifying configuration files. You will edit your infrastructure as code with the same workflow you use to make changes to other code, by opening a Pull Request (PR). Terraform Cloud pulls configuration files from their source of truth in version control to propose and apply changes to your infrastructure.
The repository you forked already includes a branch named
add-username that adds a user name attribute to your DynamoDB table. Usually, you would edit and test the configuration locally using the Terraform CLI, push the changes to a branch, and then open a PR. For this tutorial, we have made the changes for you.
Visit your forked
tfc-guide-example repo in GitHub and click "New pull request" button to create a pull request.
Set the base repository to your fork of the tfc-guide-example repo (not the fork in the HashiCorp organization) and the base branch to the
master branch. Set the the compare branch to
Note: You must create the PR against your personal forked repository. You will need to merge the PR later in this tutorial and you can't merge to the official example repo.
Then create the Pull Request by clicking through the GitHub UI.
Once you have created the pull request, Terraform Cloud will trigger a speculative plan.
Speculative plans are
- plan-only runs - they show a set of possible changes that cannot be applied
- temporary - they won't appear in any log within Terraform Cloud
- individual - they can only be accessed from a direct link on a GitHub PR
- non-destructive - no action is taken, no infrastructure is provisioned
View this plan from GitHub by clicking on the "Details" link in the "Checks" portion of your pull request.
When the speculative plan finishes, you and your teammates can review it before approving or merging the pull request. This is another way that teams can collaborate on planned infrastructure changes.
Speculative plans cannot be applied, because applying them would cause your infrastructure to differ from the configuration on your main branch of your connected repo. You must merge the pull request before you can apply 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. Terraform Cloud has picked up the change to your configuration and started a new run. When the plan completes the run will wait for your approval. Click on the new run in the Terraform Cloud UI.
Review the run details. "Confirm & Apply" the run.
In these tutorials, you configured a new workspace, provisioned infrastructure, and updated that infrastructure. Now, you're ready to destroy it.
In the next tutorial, you will clean up the resources created by your configuration and find additional learning materials on Terraform's configuration language.