3. Terraform CLI driver

3.1. Introduction

This document aims to explains the Terraform CLI driver function and how to use it.
For more information regarding the Terraform Cloud/EP driver common functions and Terraform & Terraform driver overviews, see Terraform driver Common.

3.2. Console menu structure

This section explains the Terraform CLI driver menu ustructure.

3.3. Terraform CLI driver procedure

This section explains how to use the different Terraform CLI menus

3.3.1. Terraform CLI workflow

A standard workflow using the different Terraform CLI menus can be seen below.
See the following sections for more detailed information regarding each of the steps.
Workflow
  • Workflow details and references

    1. Register Input operation name
      From the basic console's Operation list menu, register an input operation name.
      For more information, see Operation list.
    2. Register Interface information
      Configure information for the execution.
      For more information, see Interface information.
    3. Register and link Workspace
      Register information for the Terraform workspace.
      For more information, see Workspace management.
    4. Register Movement
      Register a movement.
      For more information, see Movement list.
    5. Register Module files
      Register a Module file that will be executed..
      For more information, see Module file collection.
    6. Specify Module file to Movement
      Configure the registered module file to the registered Movement.
      For more information, see Movement-Module link.
    7. Configure maximum cycles (if required)
      Configure maximum amount of cycles for the Member variable.
      For more information, see Variable nest management.
    8. Create Parameter sheet
      From the Parameter sheet creation's "Define/Create parameter sheets" menu, create a parameter sheet where the user can register data that will be used to configure the target server.
      For more information, see Parameter sheet creation function.
    9. Register data to the Parameter sheet
      In the Input menu group, access the Parameter sheet created in the previous step.From there, register data that will be used to configure the target server.
      For more information, see Parameter sheet creation function.
    10. Configure substitute value auto registration settings
      From the Substitute value auto registration settings menu, link the all the operation items and setting values registered to the Parameter sheet and the Movement variables.
    11. Execute operation
      From the Execution menu, select the previously created Movement and Input operation and execute them.
      For more information, see Execute.
    12. Confirm operation status
      In the Execution status confirmation menu, the status of all previously executed operations will be updated in realtime. Users can also monitor error logs and execution logs as well as stop them with an emergency stop.
      For more information, see Check operation status.
    13. Confirm operation history
      In the Execution management page, users can chee the history of all previously executed operations.
      For more information, see Execution management.

3.4. Function

This section explains the different functions of the menus used by the Terraform CLI driver.

3.4.1. Basic console

This section explains how to operate the Basic console menus.
For this workflow, refer to Basic console while operating the Basic console menus.

Operation list

In the Basic console▶Operation list menu, users can manage the operations executed by the different orchestrators.
For more information regarding registering Operations, see Basic console.
Submenu (Operation list)

図 3.53 Submenu (Operation list)

3.4.2. Terraform CLI driver menu

This section explains how to operate the Terraform CLI driver menus.

Interface information

  1. In the Terraform CLI▶Interface information menu, users can maintain (view/edit) execution information.
    Submenu (Interface information)

    図 3.54 Submenu (Interface information)

  2. Press the Edit button to register Interface information.
    images/ja/terraform_cli_driver/operation_method_explanation/interface_information_register.gif:width:800px:alt:Registrationpage(Interfaceinformation)

    図 3.55 Registration page (Interface information)

  3. The items in the Interface information menu are as following.
    If there is no Interface information registered, the operation execution will meet an unexpected error when multiple records are registered.

Workspace management

  1. In the Terraform CLI▶Workspace management menu, users can maintain (view/register/update/delete discarded) Workspaces used by Terraform.
    Workspaces are used as directories for executing Terraform commands.
    Even if the same workspace is target for executions, the state file generated by Terraform are managed per workspace, meaning that the indempotence will be preserved.
    Submenu (Workspace management)

    図 3.56 Submenu (Workspace management)

  2. Press the + Register button to register Workspace information.
    images/ja/terraform_cli_driver/operation_method_explanation/workspace_list_register.gif:width:800px:alt:Registrationpage(Workspacemanagement)

    図 3.57 Registration page (Workspace management)

  3. Clicking the "Delete resource" button moves the user to "Check operation status" where the target workspace will have their resources deleted (terraform destroy).
  4. The items found in the Workspace management menu are as following.

Movement list

  1. In the Terraform CLI▶Movement list menu, users can maintain (view/register/edit/discard) Movement names.
    As Movements needs to be linked to the Workspace as Terraform use information, The user will first have to register a target in Workspace management.
    Submenu (Movement list)

    図 3.58 Submenu (Movement list)

  2. Click the + Register button to register Movement information.
    images/ja/terraform_cli_driver/operation_method_explanation/movement_list_register.gif:width:800px:alt:Registrationpage(Movementlist)

    図 3.59 Registration page (Movement list)

  3. The items found in the Movement list are as following.

Module file collection

  1. In the Terraform CLI▶Module file collection menu, users can maintain (view/register/edit/discard) user created modules.
    For more inforamtion regarding writing Modules, see Describing Module.
    Submenu (Module file collection)

    図 3.60 Submenu (Module file collection)

  2. Press the + Register button to register Movement information.
    images/ja/terraform_cli_driver/operation_method_explanation/module_loist_register.gif:width:800px:alt:Registrationpage(Modulefilecollection)

    図 3.61 Registration page (Module file collection)

  3. The items found in the Module file collection menu are as following.

警告

When variables defined within the Module files (.tf format files) are extracted.
The variables defined within the Module files (.tf format files) are extracted by internal processes.
The variables can have specific values registered to them in "Substitute value auto registration settings".
The variables are not extracted in realtime, meaning that it may take time before they can be used in "Substitute value auto registration settings".

Variable nest management

  1. In the Terraform CLI▶Variable nest management menu, if the variable type defined in the tf file is "list" or "set" and the "list", "set," "tuple" or "object" is defined, the user can view and edit the Member variable's maximum number of cycles.
    The items in this menu cannot be registered, discarded or restored as BackYard manages the records based on the Module file collection.
    For more information with examples of Variable nest management, see "Variable nest management flow example".
    Submenu (Variable nest management)

    図 3.64 Submenu (Variable nest management)

  2. Press the + Edit button to edit the maximum cycle number.
    images/ja/terraform_cli_driver/operation_method_explanation/nested_variable_list_register.gif:width:800px:alt:Registrationpage(Variablenestmanagement)

    図 3.65 Registration page (Variable nest management)

  3. The items found in the Variable nest management menu are as following.

警告

※Initial registrations and repetition updates are not happening in real-time, so it might take a couple of minutes before the variables can be used in "Substitute value auto registration settings".

Substitute value auto registration settings

  1. In the Terraform CLI▶Substitute value auto registration settings menu, users can link parameter sheets (with operation) created with the Menu creation tool and Movement variables.
    The registered information is displayed in Susbtitute value management when executed by internal processes.
    Submenu (Substitute value auto registration settings)

    図 3.66 Submenu (Substitute value auto registration settings)

  2. Press the + Register button to register Substitute value auto registration settings.
    images/ja/terraform_cli_driver/operation_method_explanation/substitution_value_auto_registration_register.gif:width:800px:alt:Registrationpage(Substitutevalueautoregistrationsettings)

    図 3.67 Registration page (Substitute value auto registration settings)

  3. The items found in the Registration page are as following.
※1:Only required if the Parammeter sheet has Bundles active.
※2:Required if the selected "Movement name:Variable name" has a member variable and if the HCL settings are set to "False".
※3:Only required if the selected "Movement name:Variable name" and "Movement name:Variable name:Member variable" is a format that requires a substitute order.

注釈

For Parameter sheets with bundles
In order to link Movement variables with Parameter sheets with bundles, the user must input a substitute order for the Parameter sheet (From) in Terraform CLI▶Substitute value auto registration settings
See the following figure for more information regarding the relationship between bundled parameter sheets and Substitute value auto registration settings.
Register Substitute value auto registration settings when using Bundled parameter sheets.

図 3.68 Register Substitute value auto registration settings when using Bundled parameter sheets.

注釈

Configuring IaC variable(To) member variables
Must be configured if the variable type is object or tuple.
When configuring member variables, all the member variables of the same variable must also be configured.
If there are member variables without configured substitute values, they will not be used, even with default values.
For more information, see "※1 …Member variable targets" in "Types of variables".

注釈

IaC variable(To) substitute order
Must be configured if the variable type is either list or set.
For more information, see "※2 …Susbtitute order targets" in "Types of variables".

注釈

HCL settings
By setting the HCL settings to True, the user can configure the parameter sheets' input value (specific value) 1:1 without having to think about the variable type.
If the Variable type is set to map, they can only be registered if set to True.

Execute

In the Terraform CLI▶Execute menu, users can execute operations.
Select a Movement and Operation from the Movement list and Operation list and press the Execute button to move to the Check operation status where the execution will be processed.
Submenu (Execute)

図 3.69 Submenu (Execute)

  1. Specify reservation date
    By inputting a "Reservation date", the user can book executions and plan checks.
    Only future dates can be specified.
  2. Specify Movement
    Select a Movement registered in "Movement list".
  3. Specify Operation
    Select an Operation registered in "Operation list".
  4. Execute
    Press the Execute button to move to the "5.2.10 Execution status confirmation" menu where the execution processed will start.
    Terraform Apply will automatically be executed after Terraform Plan ends.
  5. Confirm Plan
    Clicking the "Check Plan" button operates similarly as the "Execute" button as it start the execution process. However, it will only execute, and not Terraform Apply.
  6. Confirm parameters
    Clicking the "Check parameters" button allows useres to check the input parameter values. Neither Terraform Plan nor Terraform Apply will be executed.

Tip

Output block
If a module with an output block is Executed with Conductor, the contents of the output block will be saved to the deta relay storage path(shared movement directory) as a json file.
This file allows users to use a value output by Terraform from a different Movement (in the same conductor).
File path
[Conductor Operation directory path]/[Conductor Instance ID]/terraform_output_[Execution No.].json
Conductor Operation directory path・・・Ansible ITA original variable data link's Conductor Operation directory path
Conductor Instance ID・・・ "Conductor history" のconductor Instance ID
Execution No.・・・ "Execution management" Execution No.
Description example

variable "VAR_sample" {

 type = string

 default = "sample_string"

}

output "output_sample" {

 value = "${var.VAR_sample}"

}

Output example

{

 "output_sample": {

  "sensitive": false,

  "type": "string",

  "value": "sample_string"

 }

}

Check operation status

In the Terraform CLI▶Check operation status menu, users can monitor execution statuses.
Submenu (Check operation status)

図 3.70 Submenu (Check operation status)

  1. Execution status display
    The status matching the Execution status is displayed.
    The execution log and error log also displays detailed information regarding the execution status.
    If the "Execution type" is set to "Check Plan", "Check Plan" will be displayed. If it is set to delete workspace resources (Executed from "Workspace management".), it will display "Delete resource". For everything else, "Standard".
    If the status ends in an unexpected error, and error log will be displayed in the message if there is something wrong with the registration in the "Interface information" or other web contents.
    For other errors, no message will be displayed in the error log. For those cases, the error information will be displayed in the application log.
    "Call Conductor" displays which Conductor was executed. This field will be blank if directly executed from Terraform CLI driver.
    "Execution user" displays the user that was logged in when the "Execute" button was pressed.
    ※ If "Execution type" is set to "Delete resources", the following items will not be configured.
    • Called Conductor

    • Movement

    • Operation

    • Input data

  2. Check substitute value
    Press the Check Susbtitute button to display "Susbtitute value management" where the Substitute values narrowed down to the target Operation and Movements are displayed.
  3. Emergency stop/Delete reservation
    Users can press the Emergency stop button to stop the operation.
    If the status was "Reserved execution", the Delete reservation button will be displayed. Click the Delete reservation button to delete the reservation.
  4. Display execution log
    The log file names displayed in the execution log's pulldown menu are as following.
    init.log: Terraform Init execution log
    plan.log: Terraform Plan execution log
    apply.log: Terraform Apply execution log
  5. Search log
    Users can filter information to narrow down information in the execution log and the error log.
    Input the string the user wants to search for and tick the "Corresponding lines only" checkbox to view only the lines corresponding to the string.
    The refresh interval and maximum display lines can be configured by changing the "Status monitoring cycle item" and "Progress status display lines" items in the "Interface information" menu.
  6. Input data
    Users can download executed module files and a zip file containing a list of policy materials and the configured substitute values in Json format.
    The files are as following:
    表 3.43 Input data storing file

    Folder name

    File name

    Description

    (Input Module file name)
    Stores all input nodule files within a zip file.

    terraform.tfvars
    File that contains the configured substitute value's "Variable name(key)" and "Specific value (value)".
    Will not contain said data if the Secure settings are set to True.
  7. Result data
    User can download execution logs, error logs, and state files generated by Terraform.
    The files are as following:
    表 3.44 Result data storing file

    Folder name

    File name

    Description

    init.log
    Log file that contains the contents output to the execution log(init.log).

    plan.log
    Log file that contains the contents output to the progress log(plan.log).

    apply.log
    Log file that contains the contents output to the progress log(apply.log).

    error.log
    Log file that contains the contents output to the progress (apply.log).

    result.txt
    File that documents the progress log used by the internal functions.

    .terraform.lock.hcl
    File generated by Terraform. Contains provider and module information.

    terraform.tfstate
    State file generated by Terraform.
    Saved in a decrypted state.

    terraform.tfstate.backup
    Backup of the state file generated by Terraform.
    Saved in a decrypted state.

Execution management

  1. In the Terraform CLI▶Execution management menu, the user can view execution histories.
    Specify search conditions and press the Filter button to view a table of executions.
    Pressing the Details button move sthe user to Check operation status where they can view detailed information regarding the execution status.
    Submenu (Execution management)

    図 3.71 Submenu (Execution management)

  2. The items found in the Execution management menu are as following.
    表 3.45 Item list (Execution management)

    Item

    Description

    Execution No.

    Displays an automatically given unique ID (36 characters)

    Details

    Press this button to move to the "Check operation status" menu where users can see more detailed information.

    Execution type

    Displays what type of execution was executed.

    The following types exists: "Normal" "Plan check" "Parameter sheet check"

    Status

    Displays the status of the execution. The following exists:

    "Not executed" "Not executed(Reserved)" "Preparing" "Executing" "Exe

    cuting(Delayed)" "Complete" "Complete(Error)" "Unexpected error" "Emergency stop" "Reservation deleted".

    Execution user

    Displays the name that executed the operation.

    Registration time

    Displays the time when the operation was registered.

    Movement

    ID

    Displays the ID of the Movement.

    Name

    Displays the name of the Movement.

    Delay timer

    Displays the delay timer value configured to the Movement.

    Terraform use information

    WorkspaceID

    Displays the Terraform Workspace ID configured to the Movement.

    Workspace Name

    Displays the name of the Terraform Workspace configured to the Movement.

    Operation

    No.

    Dispalys the Operation No.

    Name

    Displays the name of the Operation.

    Input data

    Allows users to download the input data in a Zip file.

    Result data

    Allows users to download the result data in a Zip file.

    Execution status

    Reservation date

    Displays the reservation date if the execution is reserved.

    Start date

    Displays when the execution will start.

    End date

    Displays when the execution will end.

    Remarks

    Free description field

Susbtitute value management

  1. In the Terraform CLI▶Susbtitute value management menu, userse can view the specific value that substitues the variables in the Module files used by the Movement linked to the Operaration.
    Submenu (Susbtitute value management)

    図 3.72 Submenu (Susbtitute value management)

  2. The items found in the Susbtitute value management menu are as following.
    表 3.46 Item list (Susbtitute value management)

    Item

    Description

    Execution No.

    Displays an automatically given unique ID (36 characters).

    Operation

    Displays the selected Operation.

    Movement name

    Displays the selected Movement.

    Movement name:Variable name

    Displays the variable name attached to the Movement selected in ":ref:

    terraform_cli_substitution_value_auto_registration_setting".

    HCL settings

    Displays whether the HCL settings configured in "Substitute value auto registration settings" are set to False or True. Variables with hierarchies containing member variables and substitute order are set to "True".

    Movement name:Member name:Member variable

    Displays the Member variable attached to the Movement selected in ":ref

    :terraform_cli_substitution_value_auto_registration_setting".

    Susbtitute order

    Displays the substitute order of the Member variable or Variable name at

    tached to the Movement selected in "Substitute value auto registration settings".

    Specific value

    Sensitive settings

    Displays either "True" or "False".

    If "True", the data will not be stored in the input data fetched from

    "Check operation status".

    Value

    Displays the Specific value of the variable used by the Operation/Movement.

    Remarks

    Free description field