Skip to main content

Terraform Cloud

Terraform Cloud is used to manage cloud infrastructure including Amazon Web Services, Google Cloud Platform, and Microsoft Azure efficiently and remotely by managing Terraform code.

Use this integration to create workflows to manage cloud infrastructure using Terraform.

Configure Terraform Cloud in Spot Connect

  1. In the left main menu, click Connect and click Settings.
  2. Under the Integrations tab, select Terraform Cloud.
  3. Configure a new integration instance with the information below.

Details needed to set up a Terraform Cloud instance in Spot Connect:

ParameterDescriptionRequired
Integration AliasA name for the integration instanceTrue
TokenTerraform Cloud API tokenTrue
OrganizationName of target Organization from Terraform CloudTrue

Follow these steps in your Terraform Cloud account to obtain the desired parameter values to enter in Spot Connect.

Create a Terraform API Token

  1. Sign in to Terraform Cloud.

  2. Click the user icon on the top left and click User Settings.

    terraform-1

  3. Click Tokens and click Create an API Token.

    terraform-2

  4. Add a description and expiration time.

  5. Click Generate Token.

    terraform-3

  6. Copy the token and paste it into the Token field of the Add Integration Instance window in the Spot Connect console.

Obtain the Terraform Organization Name

  1. Click the user icon on the top left and click User Settings.

  2. Click Organizations.

    terraform-4

  3. Copy the Organization name and paste it into the Organization field of Add Integration Instance box in the Spot Connect console.

Integration Actions

You can add these actions in the Spot Connect workflow builder as part of your workflow:

Terraform Cloud Apply

Use the action to send an http request to Terraform Cloud and apply the request.

Input

ParameterDescriptionRequired
Terraform Cloud InstanceTerraform Cloud integration in Spot ConnectTrue
Run IdString representing ID of the run to be appliedTrue

Output

ParameterTypeDescription
apply_resultString
workspace_idStringWorkspace ID from Terraform Cloud
execution_statusStringNode execution status

Action Example

  1. From the left panel, drag and drop the Terraform Cloud Apply node in the workflow builder.
  2. Select a Terraform Cloud Instance.
  3. Provide a run ID of the run you want to apply.

Input

terraform-6

Output

terraform-7

Terraform Cloud Destroy

Use the action node to destroy infrastructure that was deployed with Terraform.

Input

ParameterDescriptionRequired
Terraform Cloud InstanceTerraform Cloud integration in Spot ConnectTrue
Workspace NameString representing Terraform Cloud workspace IDTrue

Output

ParameterTypeDescription
run_idStringString representing ID of the run destroyed
run_statusStringString representing status of the run
run_dataStringJSON object containing data of the run
execution_statusStringNode execution status

Action Example

  1. From the left panel, drag and drop the Terraform Cloud Destroy node in the workflow builder.
  2. Select a Terraform Cloud Instance.
  3. Select a workspace name to remove the deployed infrastructure from.

Input

terraform-8

Output

terraform-9

Terraform Cloud Discard

Use the action node to discard Terraform run and unlock a workspace.

Input

ParameterDescriptionRequired
Terraform Cloud InstanceTerraform Cloud integration in Spot ConnectTrue
Workspace NameTerraform Cloud workspace to be unlocked; must be specified if no Run Id is givenFalse
Run IdSpecific run ID that needs to be discarded; must be specified if no Workspace Name is givenFalse

Output

ParameterTypeDescription
run_idStringRun ID that was discarded
execution_statusStringNode execution status

Action Example

  1. From the left panel, drag and drop the Terraform Cloud Discard node in the workflow builder.
  2. Select a Terraform Cloud Instance.
  3. Select a workspace name to discard a run from, or provide a run ID.

Input

terraform-10

Output

terraform-11

Terraform Cloud Plan

Use the action node to plan a Terraform run.

Input

ParameterDescriptionRequired
Terraform Cloud InstanceTerraform Cloud integration in Spot ConnectTrue
Workspace NameString representing Terraform Cloud workspace IDTrue

Output

ParameterTypeDescription
run_idStringString representing ID of the plan created
run_statusStringString representing status of the plan
run_dataStringJSON object containing data of the plan
execution_statusStringNode execution status

Action Example

  1. From the left panel, drag and drop the Terraform Cloud Plan node in the workflow builder.
  2. Select a Terraform Cloud Instance.
  3. Select a workspace name you want to send a plan request to.

Input

terraform-12

Output

terraform-13

Terraform Cloud Show

Use the action node to extract Terraform State and save to an S3 location if specified.

Input

ParameterDescriptionRequired
Terraform Cloud InstanceTerraform Cloud integration in Spot ConnectTrue
Workspace NameString representing Terraform Cloud workspace IDTrue
S3 BucketAn S3 bucket to store the extracted Terraform stateFalse
Target AliasAWS target account for the above selected S3 bucketFalse

Output

ParameterTypeDescription
bucketStringName of S3 bucket where data was stored
is_truncatedbooleanWhether output exceeded 100 KB
keyStringKey name for file in which data was stored
showStringLast 100 KB of the showed data
execution_statusStringNode execution status

Action Example

  1. From the left panel, drag and drop the Terraform Cloud Show node in the workflow builder.
  2. Select a Terraform Cloud Instance.
  3. Select a workspace name that has the state you want to extract from.

Input

terraform-14

Output

terraform-15

Terraform Cloud Update Vars

Use the action snippet to update Terraform Cloud workspace variables.

Input

ParameterDescriptionRequired
Terraform Cloud InstanceTerraform Cloud integration in Spot ConnectTrue
Workspace NameString representing Terraform Cloud workspace IDTrue
VariablesList of terraform variables needed to updateTrue

Output

ParameterTypeDescription
run_idStringString representing ID of the run destroyed
run_statusStringStatus of the run
run_dataStringResponse data of the run
execution_statusStringNode execution status

Action Example

  1. From the left panel, drag and drop the Terraform Cloud Update Vars node in the workflow builder.
  2. Select a Terraform Cloud Instance.
  3. Select a workspace name that has a variable you want to update.
  4. Hover over the variable you want to edit. Click Open JSON editor.
  5. Make changes and click Save.

terraform-14

Input

terraform-16

Output

terraform-17