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:
- Configure AWS
- Configure workspace variables
- Run a plan
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.
Warning! If you're not using an account that qualifies under the AWS free tier, you may be charged to run these examples. The most you should be charged should only be a few dollars, but we're not responsible for any charges that may incur.
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
to create a user with Programmatic access and Administrator permissions,
either through membership in an IAM Group with the
or by attaching the
AdministratorAccess policy directly.
Warning! While Terraform Cloud stores your credentials and other variables securely, we recommend disabling or deleting the user your create for this guide after you are done, and following security best practices when managing credentials.
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:
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:
AWS_ACCESS_KEY_IDwith the Access key ID from the prior step
AWS_SECRET_ACCESS_KEYwith 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:
Just like when running Terraform on your local machine, Terraform Cloud will load these environment variables when planning and applying changes to your configuration.
Note If you have been using the Terraform CLI, be aware that your local environment variables do not carry over to Terraform Cloud and you are configuring Terraform Cloud to run AWS actions on your behalf by providing your credentials.
We also included two Terraform Variables in the example configuration. Scroll up to the "Terraform Variables" section to set those up now:
When you are done, the "Terraform Variables" section should look like this:
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.
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.
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.