# Terraform Cloud

## Overview <a href="#overview" id="overview"></a>

Terraform is an open-source infrastructure as code software tool that provides a consistent CLI workflow to manage hundreds of cloud services. Terraform codifies cloud APIs into declarative configuration files.

This integration will help automate, manage and orchestrate your cloud infrastructure processes with the help of easy-to-create workflows.

## Use Cases <a href="#use-cases" id="use-cases"></a>

The integration between Fylamynt and Terraform Cloud lets you:

* Plan a terraform module.
* Apply a Terraform plan created in a workspace.
* Discard a Terraform plan in a workspace if it has not been applied. Unlocks the workspace.
* Show the output in a Workspace.
* Modify Variables in a Workspace

## Configure Terraform Cloud in Fylamynt

* Navigate to **Settings > Integrations > Terraform**
* Configure a new integration instance

Details needed to set up **Terraform Cloud instance** in **Fylamynt**:

<table data-header-hidden><thead><tr><th>Parameter Name</th><th width="378.3333333333333">Description</th><th>Required</th></tr></thead><tbody><tr><td><strong>Parameter Name</strong></td><td><strong>Description</strong></td><td><strong>Required</strong></td></tr><tr><td>Organization</td><td>The Terraform Cloud organization to be used for actions.</td><td>True</td></tr><tr><td>Token</td><td>A Terraform Cloud API token for a user in this Organization</td><td>True</td></tr></tbody></table>

Follow the steps listed below in your **Terraform Cloud** account and get the desired parameters to enter in **Fylamynt**.

* In a separate browser window or tab, Sign into Terraform Cloud
* Click on **User Settings**

![](https://2168485084-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXYvxfYq9m2JdKqaCdk%2F-MaapCbd1jsH58u7CPus%2F-MaapVBEfQlsyFKL-Ptc%2Fimage.png?alt=media\&token=3fb93509-86cd-4d61-9eb0-cd9a4f70cd93)

* Click on **Organizations**

<div align="left"><img src="https://2168485084-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXYvxfYq9m2JdKqaCdk%2F-MaapCbd1jsH58u7CPus%2F-MaapYIv8PrThDuJMymc%2Fimage.png?alt=media&#x26;token=06057d1b-8fec-4096-af2c-446544158003" alt=""></div>

* Copy the organization name into the **Organization** text field in the Fylamynt UI.
* In the **Terraform** session, click on **Tokens**

![](https://2168485084-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXYvxfYq9m2JdKqaCdk%2F-MaapCbd1jsH58u7CPus%2F-MaapdSaZIf7oT9j137K%2Fimage.png?alt=media\&token=9f08fa06-4aa6-4c32-968b-cac7e7e326be)

* Click on **Create an API token**
* Add a **Description**

![](https://2168485084-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXYvxfYq9m2JdKqaCdk%2F-MaapCbd1jsH58u7CPus%2F-Maapg0VnL1Co4S5WaDv%2Fimage.png?alt=media\&token=abbb1096-c343-4e5a-90f9-91d85b6c8e88)

* Click on **Create API token**
* Copy the new token into the **Token** text field in the Fylamynt UI

## Integration Actions

1. [Terraform Apply](#terraform-apply)
2. [Terraform Discard](#terraform-discard)
3. [Terraform Plan](#terraform-plan)
4. [Terraform Show](#terraform-show)
5. [Terraform Update Vars](#terraform-update-vars)

### Terraform Apply

Apply a Terraform plan created in a workspace.

**Input**

| **Parameter Name** | **Description**                        | **Required** |
| ------------------ | -------------------------------------- | ------------ |
| alias              | Target account for running this action | True         |
| run\_id            | Run id from a previous Terraform Plan  | True         |

**Output**

| **Parameter Name** | **Type** | **Description**                               |
| ------------------ | -------- | --------------------------------------------- |
| apply\_result      | String   | Status of the Apply action                    |
| workspace\_id      | String   | The workspace Id in which the action occurred |

### Terraform Discard

Discard a Terraform plan in a workspace if it has not been applied. Unlocks the workspace. Either **run\_id** or **workspace\_id** should be specified.

**Input**

| **Parameter Name** | **Description**                           | **Required** |
| ------------------ | ----------------------------------------- | ------------ |
| alias              | Target account for running this action    | True         |
| run\_id            | Run id from a previous Terraform Plan run | False        |
| workspace\_id      | Id of locked Workspace                    | False        |

**Output**

| **Parameter Name** | **Type** | **Description**                                                             |
| ------------------ | -------- | --------------------------------------------------------------------------- |
| run\_id            | String   | The run id that was discarded. Can be None if the workspace was not locked. |

### Terraform Plan

Plan a terraform module. This action does not apply the plan automatically.

**Input**

| **Parameter Name** | **Description**                                                      | **Required** |
| ------------------ | -------------------------------------------------------------------- | ------------ |
| workspace\_id      | Id picked from the list of workspaces available to this organization | True         |

**Output**

| **Parameter Name** | **Type** | **Description**                                |
| ------------------ | -------- | ---------------------------------------------- |
| run\_id            | String   | The run id for this action.                    |
| run\_status        | String   | The status of the run when the action finishes |
| run\_data          | String   | JSON object containing the data of the plan.   |

### Terraform Show

Show the output in a Workspace.

**Input**

| **Parameter Name** | **Description**                                                      | **Required** |
| ------------------ | -------------------------------------------------------------------- | ------------ |
| workspace\_id      | Id picked from the list of workspaces available to this organization | True         |
| alias              | Target account for running this action                               | True         |
| bucket             | S3 bucket for storing the output                                     | False        |

**Output**

| **Parameter Name** | **Type** | **Description**                                                                                      |
| ------------------ | -------- | ---------------------------------------------------------------------------------------------------- |
| is\_truncated      | Boolean  | True if the output in showhad to be truncated.                                                       |
| bucket             | String   | The name of the output bucket if provided in the **inputs**                                          |
| key                | String   | The S3 key for the output if a bucket was provided in the **inputs.** This will have all the output. |
| show               | String   | The output (or the last 100 KB if truncated)                                                         |

### Terraform Update Vars

Modify **Variables** in a Workspace

**Input**

| **Parameter Name** | **Description**                                                      | **Required** |
| ------------------ | -------------------------------------------------------------------- | ------------ |
| workspace\_id      | Id picked from the list of workspaces available to this organization | True         |
| variables          | List of JSON dictionaries for variables set up for this workspace    | True         |

**Output**

| **Parameter Name** | **Type**                   | **Description**                |
| ------------------ | -------------------------- | ------------------------------ |
| variables          | List of JSON dictionaries. | Variables updated by the user. |

**Action Example**

![](https://2168485084-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXYvxfYq9m2JdKqaCdk%2F-MaapCbd1jsH58u7CPus%2F-MaarCjZRtWh8etHedAe%2Fimage.png?alt=media\&token=2b5362dc-89cb-4519-80ed-5709005ea487)
