Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »


Disclaimer

Your use of this download is governed by Stonebranch’s Terms of Use, which are available at https://www.stonebranch.com/integration-hub/Terms-and-Privacy/Terms-of-Use/

Overview

Terraform is an infrastructure as code tool that lets you define both cloud and on-prem resources in human-readable configuration files that you can version, reuse, and share. You can then use a consistent workflow to provision and manage all of your infrastructure throughout its lifecycle.

This Universal Extension allows to create tasks that execute terraform commands. Typically, it can be used for Use Cases where UAC acts as an orchestrator for resource provisioning and Terraform needs to be used to provision those resources.

Software Requirements

This integration requires Terraform, Universal Agent and Python runtime to execute the Universal Task.

Software Requirements for Universal Template and Universal Task

  • Requires Python 3.7.0 or higher. Tested with the Universal Agent bundled Python distribution.
  • Requires Terraform 1.0.0 version or higher.

Terraform is required to be installed on the host where agent is installed. Related Terraform binaries and libraries needs to be accessible by the agent.

Software Requirements for Universal Agent

Linux agents are supported:

  • Universal Agent for Linux Version 7.0.0.0 and later with python options installed.

Software Requirements for Universal Controller

Universal Controller Version 7.0.0.0 and later.

Network and Connectivity Requirements

Extension's Universal Agent host should be able to reach endpoints of services related to resource provisioning used by Terraform.

Key Features

This Universal Extension supports the following main features:

Import Universal Template

To use the Universal Template, you first must perform the following steps:

  1. This Universal Task requires the Resolvable Credentials feature. Check that the Resolvable Credentials Permitted system property has been set to true. For more information about Resolvable Credentials click here.

  2. To import the Universal Template into your Controller, follow the instructions here.

  3. When the files have been imported successfully, refresh the Universal Templates list; the Universal Template will appear on the list.

Configure Universal Task

For the new Universal Task type, create a new task, and enter the task-specific details that were created in the Universal Template

Input Fields

FiledInput typeDefault valueTypeDescription
ActionRequiredInitChoiceTerraform command.
Valid values are:
  • Init
  • Plan
  • Apply
  • Destroy
Upgrade PluginsOptionalFalseBooleanIf selected, this flag upgrades all previously-selected plugins to the newest version that complies with the configuration's version constraints. This will cause Terraform to ignore any selections recorded in the dependency lock file, and to take the newest available version matching the configured version constraints.
Variables ScriptOptionalEmptyScriptUAC script that contains Terraform input variables including all required credential mappings
Plan Output FileOptionalEmptyTextThe file that contains the resulting plan of the Terraform "Plan" command. If file already exists it will be overwritten.
Plan FileOptionalEmptyTextThe plan file that is applied.
Planning modeOptionalNoneChoiceThe Terraform Planning Mode that is applied.
Print Log on STDERROptionalTrueBooleanIf selected, Terraform log will be printed on STDERR.
JSON OutputOptionalFalseBooleanIf selected, Terraform log will be printed in JSON format.
Runtime DirectoryOptionalEmptyTextThis is the path where all the terraform files, plugins and execution will be performed. It should be also the path to .tf file.

Task Examples

Terraform Init

Init action with default fields

Terraform Plan

Plan action with provided Plan Output File, Variables Script, Printing logs in json format and PATH variable to terraform binary

Variable Script:

Terraform Apply

Apply action with provided Plan File, Variables Script, Printing logs in json format and PATH variable to terraform binary

Terraform Destroy

Destroy action with Printing logs in json format and PATH variable to terraform binary

Task Output

Exit Codes

The exit codes for this Universal Extension are described below.

Exit CodeStatus Classification CodeStatus Classification DescriptionStatus Description
0SUCCESSSuccessful ExecutionSUCCESS: Terraform command executed successfully!
1FAILFailed ExecutionFAIL: Unexpected error. See STDERR for more details.
20DATA_VALIDATION_ERRORInput fields validation errorDATA_VALIDATION_ERROR: Some of the input fields cannot be validated. See STDERR for more details.

Extension Output

Upon Task's successful completion, the extension produces an Extension Output similar to the one in the example below:

{
  "exit_code": 0,
  "status_description": "SUCCESS: Terraform command executed successfully!",
  "changed": true,
  "invocation": {
    "extension": "ue-terraform",
    "version": "1.0.0",
    "fields": {
      "action": "Init",
      "upgrade_plugins": false,
      "variables_script": "",
      "plan_file": "",
      "plan_output_file": "",
      "planning_mode": [],
      "print_log_on_stderr": true,
      "json_output": false
    }
  },
  "result": {
    "commands": [
      {
        "cmd": "terraform init -no-color -input=false",
        "rc": 0
      }
    ]
  }
}

Attribute result.commands provides information for the Terraform executed command. It contains the following sub-attributes.

AttributeOutput TypeTypeDescription
cmdMandatoryTextThe executed command
rcMandatoryIntegerReturn code of executed command.

The Extension Output for UE Terraform is described below.

Attribute changed is populated as follows

  • null, in case Action is Init/Apply/Destroy
  • false, in case Action is Plan, and it has succeeded with empty diff (no changes)
  • true, in case Action is Plan, and it has succeeded with non-empty diff (changes present)

If subsequent tasks in a workflow reply on the output of this Universal Extension then they should rely on Extension Output.

STDOUT and STDERR

STDOUT and STDERR provide additional information to User. The populated content can be changed in future versions of this extension without notice.

Document References

NameLocationDescription
Universal Templateshttps://docs.stonebranch.com/confluence/display/UC72x/Universal+TemplatesUser documentation for creating Universal Templates in the Universal Controller user interface.
Universal Taskshttps://docs.stonebranch.com/confluence/display/UC72x/TasksUser documentation for creating Universal Tasks in the Universal Controller user interface.
Resolvable Credentialshttps://docs.stonebranch.com/confluence/display/UC72x/Credentials#Credentials-ResolvableCredentialsResolvableCredentialsUser documentation: Resolvable Credentials.
Resolvable Credentials Permittedhttps://docs.stonebranch.com/confluence/display/UC72x/Properties#Properties-ResolvableCredentialsPermittedUser documentation: Resolvable Credentials Permitted Property.
Terraform Introhttps://www.terraform.io/introIntroduction to Terraform official documentation
Terraform Clihttps://www.terraform.io/cliTerraform Cli official documentation
  • No labels