Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Changes for v1.0.1

...

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.Stonebranch users to orchestrate infrastructure provisioning processes using Terraform.

Version Information

Template NameExtension NameExtension Version
Terraformue-terraform1.0.1

Software Requirements

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

...

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

...

Linux agents are supported:.

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

...

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:.

...

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.

...

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
ActionRequiredInitChoice

Terraform command.

Valid The valid values are :as follows.

  • Init
  • Plan
  • Apply
  • Destroy
Upgrade PluginsOptionalFalseBoolean

If 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.

Visible only when Action is "Init".

Terraform Credentials

Introduced in version 1.0.1
Optional-CredentialsCredentials that can be passed to the Variable Script. When the task is launched, they will be resolved and be part of the generated terraform variables file to be used when executing the terraform command.

More information on how to use the Terraform Credentials can be found here.

Visible when Action is "Plan", "Apply" or "Destroy".
Variables ScriptOptionalEmptyScriptUAC script that contains Terraform input variables including all required credential mappings
Plan Output FileOptionalEmptyTextFile that contains the resulting plan of the Terraform "Plan" command. If

Specifies the file name for the generated plan. If the file already exists, it will be overwritten.

Visible only when Action = "Plan".

Plan FileOptionalEmptyTextPlan file that is applied

Path to a previously generated plan file that will be used when applying a new configuration.

Visible only when Action = "Apply".

Planning modeOptionalNoneChoiceTerraform Planning Mode that is will be applied.
The valid values are as follows.
  • None
  • Refresh-only Mode
Print Log on STDERROptionalTrueBoolean

If selected the generated, Terraform log will be printed on STDERR.

When not selected, the Terraform log is not printed.

JSON OutputOptionalFalseBoolean

If selected, Terraform log will be printed in JSON format.

Visible only when Print Log on STDERR = "True".

Runtime DirectoryOptionalEmptyTextPath where all Terraform files, plugins, and execution will be performed. It should be also the path to .tf file

Directory in which the application should be executed.

It needs to contain the Terraform .tf files, as well as any additional mandatory Terraform files required for the specific action.

Task Examples

Terraform Init

Init action with default fieldsImage Removedsetting the runtime directory where the Terraform will be initialized.

Image Added

Terraform Plan

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

Image Removed

Variable Script:

Image Removed

JSON format on STDERR using a specific runtime directory.

Image Added

Terraform Apply

Apply action with provided Plan File, Variables Script, Printing logs in json format and PATH variable to terraform binary.Image Removedusing a specific runtime directory.

Note

When Terraform is using a previously generated plan file, variable scripts can not be re-evaluated.

Image Added

Anchor
variable-script
variable-script
Variable Script

Passing credentials from the template to the terraform variable file.
One credential field can be passed, the configuration of which can be used to allow users to pass credentials into variable scripts. User has the freedom to decide which credential parameters (like "Runtime User", Runtime Password", "Key Location") can be used from the credential field to propagated to the variables script.

Image Added

Terraform Destroy

Destroy action with Printing logs in json format and PATH variable to terraform binaryImage RemovedJSON format using a specific runtime directory.

Image Added

Task Output

Exit Codes

...

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:In the context of a workflow, subsequent tasks can rely on the information provided by this integration as Extension Output.

Attribute changed is populated as follows.

nullIf Action is Init/Apply/Destroy.
falseIf Action is Plan, and it has succeeded with empty diff (no changes).
trueIf Action is Plan, and it has succeeded with non-empty diff (changes present).

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.

An example of the Extension Output for a execution of Init action is presented below.

{
  "exit_code": 0,
  "status_description": "SUCCESS: Terraform command executed successfully!",
  "changed": true,
  "invocation": {
    "extension": "ue-terraform",
    "version": "1.0.

...

1",
    "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.

...

The Extension Output for Terraform is described below.

Attribute changed is populated as follows:

...

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


STDOUT and STDERR

STDOUT and STDERR provide additional information to Useruser. The populated content can be changed in future versions of this extension without notice. Backward compatibility is not guaranteed.

Document References

Universal Templates
NameLocationDocument LinkDescription
https://docs.stonebranch.com/confluence/display/UC72x/Universal + TemplatesUser documentation for creating, working with and understanding Universal Templates in the Universal Controller user interfaceand Integrations.
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 Credentialsfor creating and working with credentials.
Resolvable Credentials Permitted https://docs.stonebranch.com/confluence/display/UC72x/Properties#Properties-ResolvableCredentialsPermittedUser documentation: PropertyUser documentation for Resolvable Credentials Permitted Property.
Terraform Introhttps://www.terraform.io/introIntroduction to Terraform official documentation
Terraform Clihttps://www.terraform.io/cliTerraform Cli official documentation

Changelog

ue-terraform-1.0.1 (2022-07-19)

Enhancements

  • Fixed: Credentials can now be passed from Credential field to the variable script.