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 randomly-named Amazon DynamoDB table by forking a GitHub repo that contains the table's configuration, connecting the repo to Terraform Cloud, and queuing your first Terraform Cloud run.
»Prerequisites
While Terraform can provision resources on many different providers and connect with several popular version control systems (VCSs), this tutorial requires:
- an AWS account
- a GitHub account
»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.tf
specifies the provider plugin that connects Terraform Cloud to the AWS API, and 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.tf
defines variables that are referenced inmain.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.tf
defines the information about your infrastructure that Terraform Cloud will return to you when it makes changes.
»Connect Terraform Cloud to GitHub
Create a new workspace for your configuration by choosing "Workspaces" from the main menu, and clicking the "New Workspace" button.
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.
»Next Steps
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.