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

Getting Started - Terraform Cloud

Set Up Workspace

Now that you have created your workspace and connected it to your GitHub repository, you can set it up and apply the configuration. To do so, you will need to follow a few steps:

  1. Configure AWS
  2. Configure workspace variables
  3. Run a plan

Configure AWS

The example repository uses the Amazon Web Services (AWS) provider. In order to use it, you will need an AWS account.

If you don't have an AWS account already, create one now.

This example is intended to create only resources which qualify under the AWS free tier.

Once you have an AWS account, you'll need user credentials so that Terraform can use your AWS account to apply the example configuration.

You can follow the AWS documentation to create a user with Programmatic access and Administrator permissions, either through membership in an IAM Group with the AdministratorAccess policy, or by attaching the AdministratorAccess policy directly.

When you create the user, you will receive an Access key ID and a Secret access key. Be sure to keep these values in a secure location, we'll be using them in the next step.

Configure workspace variables

Now that you have your AWS Access key ID and Secret access key, return to the Terraform Cloud UI. Within your new workspace, visit the "Variables" page:

Workspace Variables

Terraform Cloud supports both Terraform Variables and Environment Variables. We'll use both types in this guide.

Now, scroll down to the "Environment Variables" section, and create two variables:

  1. AWS_ACCESS_KEY_ID with the Access key ID from the prior step
  2. AWS_SECRET_ACCESS_KEY with the Secret access key

Check the "Sensitive" checkbox for both of these variables and click the "Save variable" button to save each one. Once you are done, the "Environment Variables" section should look like this:

Environment Variables

Just like when running Terraform on your local machine, Terraform Cloud will load these environment variables when planning and applying changes to your configuration.

We also included two Terraform Variables in the example configuration. Scroll up to the "Terraform Variables" section to set those up now:

  1. tag_user_name with your name
  2. db_write_capacity with the number 1
  3. db_read_capacity with the number 2

When you are done, the "Terraform Variables" section should look like this:

Terraform Variables

Run a plan

Now that your workspace is configured, use the "Queue Plan" button to start a plan. You may give a reason in the provided text box. Terraform Cloud will run a plan step, just like running terraform plan from the command line.

Queue Plan

Running the plan may take a few minutes. Once the plan is complete, you should see that the plan needs confirmation before it is applied. This is equivalent to the terraform commandline asking you to confirm a plan before applying the change.

Click the "Confirm & Apply" button to continue. You can include a comment if you like.

After a few minutes, your plan should be applied successfully, and you can see the results in Terraform Cloud.

Terraform Apply

The example configuration we provided configures a simple AWS DynamoDB table. You can visit the AWS console to confirm that the table was provisioned. The configuration defaults to using the N. California/us-west-1 region, so be sure to look for the DynamoDB table in that region.

There have been several steps involved in getting to this point, so it is possible that a missed step, typo, or other problem could result in an error. If an error does occur during the plan or apply step, Terraform Cloud will display the error message to help you troubleshoot the problem.

Next, you will see how to apply changes to your configuration.

Remember that the DynamoDB table that you have provisioned will remain active until it is deleted. We will do that later on in this guide in the cleanup section.