Add Terraform Scripts
This topic describes how to set up a Harness Infrastructure Provisioner for Terraform.
Once the Harness Infrastructure Provisioner is set up, you can use it to do the following:
- Define a deployment target in a Harness Infrastructure Definition, provision the target infrastructure in a Workflow as part of its pre-deployment step, and then deploy to the target infrastructure.
- Provision any non-target infrastructure.
Harness supports first class Terraform provisioning for AWS-based infrastructures (SSH, ASG, ECS, Lambda), Google Kubernetes (GKE), Azure WebApps, and physical data centers via shell scripts.
Harness Terraform Infrastructure Provisioner are only supported in Canary and Multi-Service Workflows. For AMI/ASG and ECS deployments, Terraform Infrastructure Provisioners are also supported in Blue/Green Workflows.
Before You Begin
- Get an overview how how Harness supports Terraform: Terraform Provisioning with Harness.
- Ensure you have your Harness account settings prepared for Terraform: Set Up Your Harness Account for Terraform.
Review: Terraform Syntax Support
Harness supports Terraform scripts written in Terraform syntax versions 11 and 12.
Terraform Syntax Support for Versions 13-1.0
Currently, this feature is behind the Feature Flag TERRAFORM_CONFIG_INSPECT_VERSION_SELECTOR
. Contact Harness Support to enable the feature.When this feature flag is enabled, Harness supports Terraform scripts written in Terraform syntax versions 11, 12, 13, 14, 15, and 1.0.
Visual Summary
This topic describes step 1 in the Harness Terraform Provisioning implementation process displayed below.
The graphic shows how the scripts you add in this topic are used to provision the target infrastructure for a deployment:
Once you have completed this topic:
- If you are going to provision the deployment target infrastructure, move onto the next step: Map Dynamically Provisioned Infrastructure using Terraform.
- If want to simply provision any non-target infrastructure, see Terraform Provisioning with Harness.
Step 1: Add a Terraform Provisioner
To set up a Terraform Infrastructure Provisioner, do the following:
In your Harness Application, click Infrastructure Provisioners.
Click Add Infrastructure Provisioner, and then click Terraform. The Add Terraform Provisioner dialog appears.
In Name, enter the name for this provisioner. You will use this name to select this provisioner in Harness Infrastructure Definitions and the Workflow steps Terraform Provision, Terraform Apply, and Terraform Destroy.
Click Next. The Script Repository section appears. This is where you provide the location of your Terraform script in your Git repo.