HashiCorp Terraform

5 minute readExtensibilityDeveloper productivity

HashiCorp Terraform enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.

The EC-Terraform plugin orchestrates infrastructure actions in Terraform, allowing users to plan, configure, provision and destroy infrastructure in Terraform. These actions can be integrated into CloudBees CD/RO processes—​such as provisioning infrastructure dynamically at deployment time, automatically destroying test infrastructure when it is no longer needed, and incorporating infrastructure management and configuration actions into delivery pipelines.

Plugin version 3.0.2.2021071947

Revised on July 14, 2021

Plugin configurations

Plugin configurations are sets of parameters that apply across some or all of the plugin procedures. They reduce repetition of common values, create predefined parameter sets for end users, and securely store credentials where needed. Each configuration is given a unique name that is entered in designated parameters on procedures that use them.

Creating plugin configurations

To create plugin configurations in CloudBees CD, do these steps:

  • Go to Administration Plugins to open the Plugin Manager.

  • Find the EC-Terraform-3.0.2.2021071947 row.

  • Click Configure to open the Configurations page.

  • Click Create Configuration as per the description of parameters below.

Configuration procedure parameters

ParameterDescription

Configuration Name

The name for the created configuration.

Description

Description of the configuration.

Terraform Client Command

Command that will be used as terraform client, like /usr/bin/terraform or /my/custom-terraform, or sudo terraform, etc.

Terraform Working Directory

Working Directory where commands will be executed. If not set, commander workspace will be used.

Terraform Variables File Location

Variables file location. Could be one of: none, new file, existing file.

Terraform Variables File Location

Absolute path to Terraform var file. This file will be passed to Terraform using --var-file= option.

Terraform Variables File Content

If you are using resource files that reference external variables, set these variables here. These variables will be written to a temporary file and will be passed to Terraform using the --var-file= option.

Terraform Workspace

Workspace of terraform to be used during terraform operations. If it is not set, default workspace will be used. Terraform will switch to this workspace before any applicable action. If this workspace does not exist, it will be created.

Auth Type

Mechanism to provide an authentication data into the Terraform command call.

In order to use AWS driver, your Terraform playbook should contain aws {} block.

AWS Credentials

AWS Client ID and Secret Key to authorize the Terraform call. They will be added to the command call as envronment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

AWS Session Token

AWS Session Token to use in the authentication (if needed). It will be added to the call as an environment variable AWS_SESSION_TOKEN.

Debug Level

This option sets debug level for logs. If info is selected, only summary information will be shown, for debug, there will be some debug information and for trace the whole requests and responses will be shown.

Plugin procedures

Init

Executes terraform init command

Init parameters

ParameterDescription

Configuration Name

Previously defined configuration for the plugin

Additional Command Line Arguments

Arguments for command line, for example: -var 'foo=bar'.

Plan

Executes terraform plan command

Plan parameters

ParameterDescription

Configuration Name

Previously defined configuration for the plugin

Terraform Plan Name

File name that will be used as terraform plan.

Additional Command Line Arguments

Arguments for command line, for example: -var 'foo=bar'.

Apply

Executes terraform apply command

Apply parameters

ParameterDescription

Configuration Name

Previously defined configuration for the plugin

Terraform Plan Name

File name that will be used as terraform plan.

Additional Command Line Arguments

Arguments for command line, for example: -var 'foo=bar'.

Output Property

Property name used to store the results of the terraform show command if provisioning was successful.

Destroy

Executes terraform destroy command

Destroy parameters

ParameterDescription

Configuration Name

Previously defined configuration for the plugin

Additional Command Line Arguments

Arguments for command line, for example: -var 'foo=bar'.

Provision

Provisions Environments using Terraform

Provision parameters

ParameterDescription

Configuration Name

Previously defined configuration for the plugin

Source of Terraform Config File

Location type of config file

Terraform Config File Location

Location of Terraform Config file in file system. This file will be copied to terraform working directory.

Terraform Config File Content

Content of Terraform Config file to be written.

Output Property

Property name used to store the results of the terraform show command if provisioning was successful.

RunCustomCommand

Runs Terraform Custom Command

RunCustomCommand parameters

ParameterDescription

Configuration Name

Previously defined configuration for the plugin

Terraform Command

Terraform command to use. For example: init.

Additional Command Line Arguments

Arguments for command line, for example: -var 'foo=bar'.

Ouput Property Path

This property will contain procedure execution output.

Switch Workspace?

If checked, terraform will be switched to workspace from configuration.

Apply var-file?

If checked, variables file from configuration will be applied to custom command.

CreateTerraformConfig

Creates terraform config in terraform working directory

CreateTerraformConfig parameters

ParameterDescription

Configuration Name

Previously defined configuration for the plugin

Terraform Config File Name

Name of config file to be written. Warning: If this file already exists, it will be overwritten.

Source of Terraform Config File

Source of terraform config file. Could be one of: Existing File, New File.

Terraform Config File Location

Location of Terraform Config file in file system. This file will be copied to terraform working directory.

Terraform Config File Content

Content of Terraform Config file to be written.

Release notes

EC-Terraform 3.0.2

  • The logic of handling existing var files has changed. Now, env files are referenced by their location instead of copying them to the workspace.

EC-Terraform 3.0.1

  • The issue when Init procedure was not able to swith Terraform workspace has been fixed.

  • The issue with context-dependent properties in the configuration during procedure execution has been fixed.

EC-Terraform 3.0.0

  • The plugin has been migrated to PDK framework. As a result, support for external credentials has been added.

  • Added support for secure credentials with Amazon AWS.

EC-Terraform 2.0.3

  • Fixed an issue with the "Apply", "Destroy" and "Init" procedure parameters.

EC-Terraform 2.0.2

  • Fixed an issue with the "Plan" procedure parameters.

EC-Terraform 2.0.1

  • The documentation has been migrated to the main documentation site.

EC-Terraform 2.0.0

  • The following two new procedures have been introduced

    • RunCustomCommand

    • CreateTerraformConfig

    • The following existing procedures have been modified

    • Init, Plan, Apply and Destroy procedures now allow additional options to be passed in.

    • Support for Terraform Workspace has been added in order to support multiple named workspaces.

    • Procedure setup screens leverage the dynamic form capability where parameters are conditionally rendered based on dropdown values.

    • Provision procedure now takes both Config and Variables file content as Input from a text area.

  • The plugin icon has been updated.

EC-Terraform 1.2.1

  • Configured the plugin to allow the CloudBees CD UI to render the plugin procedure parameters entirely using the configured form XMLs.

  • Enabled the plugin for managing the plugin configurations in-line when defining an application process step or a pipeline stage task.

EC-Terraform 1.2.0

  • Added new Provision procedure

EC-Terraform 1.1.0

  • Following procedures have been added:

    • Init

    • Plan

    • Apply

    • Destroy

EC-Terraform 1.0.0

  • Introduced the EC-Terraform plugin.