The HashiCorp Terraform integration enables you to manage your primary resources directly from Torq workflows.
Accounts
Cost estimates
OAuth clients
Organizations
Runs
Subscriptions
Variables
Workspaces
Workspace notifications
Use Terraform Cloud Steps in a Workflow
Get your Terraform API token
Depending on how you want to interact with Terraform in Torq, you need to generate and use the proper API token. Torq tested and verified that all Terraform steps in Torq can be run with a User token.
User tokens: each Terraform Cloud user can have any number of API tokens, which can make requests on their behalf.
Team tokens: each team can have one API token at a time. This is intended for performing plans and applies via a CI/CD pipeline.
Organization tokens: each organization can have one API token at a time. This is intended to automate the management of teams, team membership, and workspaces. The organization token cannot perform plans and applies.
User Token
Click your user avatar/user photo.
Select User Settings.
Go to Tokens.
Click the Create an API token button.
Give the token a meaningful description, such as,
Token for Torq workflows
and click Create API token.
Team Token
Go to the organization where the team exists.
Click Settings and go to Teams.
Click the Create a team token button.
Copy the token and save it. It will not be displayed again.
Organization Token
Go to the organization.
Click Settings > API tokens.
Click the Create an organization token button.
Copy the token and save it. It will not be displayed again.
Create a Terraform Clouds Steps Integration in Torq
The integration stores the API token. The integration is used to authenticate Terraform steps in a workflow.
Go to Build > Integrations > Steps > HashiCorp Terraform and click Add.
Give the integration a meaningful name.
Paste the API key you created earlier.
Use Run Tasks to Trigger Torq Workflows
You can trigger Torq workflows with events from Terraform using run tasks.
Create a Terraform Cloud trigger integration in Torq
The integration generates a unique endpoint URL in Torq. You'll use this URL as the Webhook URL when you create a run task or notification in Terraform Cloud.
Go to Integrations > Triggers > Terraform Cloud and click Add.
Give the integration a meaningful name, for example,
terraform-run-task
orterraform-notification
.Copy the endpoint URL. You'll need this when creating a run task in Terraform Cloud.
Create a Run Task
Run tasks are created on the organization level and applied on the workflow level.
In your Terraform Cloud instance, go to the appropriate organization and click Settings > Run tasks > Create run task.
Complete the Create a Run Task form and click Create run task.
a. Name: a meaningful name for the run task, for example,torq-run-task
.
b. Endpoint URL: the Torq endpoint URL you created and copied earlier.
c. Description (optional): explain what this run task is.
Trigger a Workflow with a Run Task
At this point, you've created a Terraform Cloud trigger integration in Torq, which generated a unique endpoint in Torq. You then associated this endpoint with a run task in Terraform Cloud.
In Torq, go to the Workflows page and click Create Workflow.
Select the Integrations trigger, click the Terraform Cloud card, and select the integration you created.
To send information back to the run task, add an HTTP Request step for each data item you want to send. If a callback is not performed within 10 minutes of the run task being triggered, the task will fail. Use all of the values below to configure the HTTP Request step. The BODY parameter will vary depending on the data you're sending back to the run task.
Premade Steps
These are the premade steps for Terraform Cloud. Don't see a step you need? No problem, you can easily create custom steps.
Apply run plan
Create organization
Create run plan
Create VCS workspace
Delete organization
Delete workspace
Get account details
Get subscription details
List OAuth clients
List organizations
List workspace notifications
List workspaces
List workspace variables
Run task callback