Once you've created a Terraform Cloud account and created or joined an organization, you can start managing version-controlled infrastructure with Terraform Cloud.
In this tutorial, you will create a version control system (VCS) driven Terraform Cloud workspace by connecting a sample repository to Terraform Cloud. This Terraform Cloud workspace will provision a randomly-named AWS DynamoDB table.
While Terraform can provision resources on many different providers and connect with several popular version control systems (VCSs), this tutorial requires:
»Fork a Github repository
Visit this example GitHub repository, which contains the Terraform configuration for your DynamoDB table.
Click the "Fork" button at the top right of the page to copy the repository to your GitHub account.
Explore your fork of the repository. It contains Terraform configuration files, which define and expose information about your infrastructure:
main.tfspecifies the AWS provider, a provider plugin that connects Terraform Cloud to the AWS API, and the random provider, another provider that will generate the random name for the table. It also defines resources that represent the table name and the table itself, with the information that AWS needs to know about the table's settings.
variables.tfdefines variables that are referenced in
main.tf, which make the configuration easy to customize and collaborate on. You will set some of these values in the Terraform Cloud UI later on in this tutorial.
outputs.tfdefines the information about your infrastructure that Terraform Cloud will return to you when it makes changes.
versions.tfdefines version constraints for Terraform, the AWS provider and the random provider.
»Connect Terraform Cloud to GitHub
Navigate to the "Workspaces" page from the main menu and click "+ New workspace."
On the "New Workspace" page, select the "Version control workflow" from the workflow options screen. On the "Connect to VCS" screen, press the "GitHub" button and then choose "GitHub.com" from the drop-down to continue.
A new window will open asking you to authorize Terraform Cloud to use your GitHub account. Click the green "Authorize" button to connect Terraform Cloud to your GitHub account.
You may be asked to install Terraform Cloud for your GitHub account/organization. If prompted, select your account/organization to install Terraform Cloud.
For information about installing Terraform Cloud on GitHub, refer to the Terraform Documentation: Configuration-Free GitHub Usage.
»Choose a repository
Next, Terraform will display a list of your GitHub repositories. Choose the repository you forked, called "tfc-guide-example". If you have a lot of GitHub repositories, you may need to filter the list to find the correct one.
»Create the workspace
On the next screen, leave the workspace name and "Advanced options" unchanged, and click the purple "Create workspace" button to create the workspace.
It will take a few minutes for Terraform Cloud to connect to your GitHub repository. Once connected, Terraform Cloud will display a notification that your configuration was uploaded successfully.
In this tutorial, you created a workspace and connected it to your GitHub repository. Read more about Terraform Cloud workspaces in the documentation.
Next, you will configure your new workspace with variables and provision your infrastructure by queuing a run in Terraform Cloud.