Importing Existing Harness Infrastructure into Terraform - Step by Step

1.) Go to and search for the resource you’d like to import using the Filter on the left hand side. For example harness_platform_pipeline.

2.) Scroll down to the bottom of the page for a line similar to this:

terraform import harness_platform_pipeline.example <org_id>/<project_id>/<pipeline_id>

This is the line you will need to run after creating the file and running terraform init.

3.) Create a file with similar contents:

terraform {
  required_providers {
    harness = {
      source = "harness/harness"

#Configure the Harness provider for Next Gen resources
provider "harness" {
  endpoint         = ""
  account_id       = "your_account_id_goes_here"
  platform_api_key = "your_api_key_goes_here"

resource "harness_platform_pipeline" "example" {}

4.) Run:

terraform init

5.) Run:

terraform import harness_platform_pipeline.example <org_id>/<project_id>/<pipeline_id>

substituting any necessary values

For example:

terraform import harness_platform_pipeline.example testorg/CSETest1/test_pipeline_123

6.) Inspect the state file (terraform.tfstate). It should have the resource assuming no errors occurred.

7.) Run:

terraform show

which will give you an output similar to the following:

# harness_platform_pipeline.example:
resource "harness_platform_pipeline" "example" {
    id               = "test_pipeline_123"
    identifier       = "test_pipeline_123"
    name             = "test_pipeline_123"
    org_id           = "testorg"
    project_id       = "CSETest1"
    template_applied = false
    yaml             = <<-EOT
          name: test_pipeline_123
          identifier: test_pipeline_123
          projectIdentifier: CSETest1
          orgIdentifier: testorg
          tags: {}
            - stage:
                name: testing
                identifier: testing
                description: ""
                type: Approval
                      - step:
                          type: ShellScript
                          name: Shell Script_1
                          identifier: ShellScript_1
                            shell: Bash
                            onDelegate: true
                              type: Inline
                                script: echo "hello world"
                            environmentVariables: []
                            outputVariables: []
                          timeout: 15m
                tags: {}

8.) Copy over the output from step 7 into the file.

9.) Remove the line with id.

For example:

id               = "test_pipeline_123"

10.) At this point you can modify and run

terraform apply

For example modify line with

timeout: 15m

to be

timeout: 30m

and run

terraform apply