-1

I am trying to create a pipeline in concourse, which is going to trigger on github updates on a remote branch, and use that branch to plan, apply and destroy a terraform deployment.

- name: terraform-repo
  type: git
  icon: github
  source:
    uri: https://github.com/....

#docker image
- name: terraform-0-13-7
  type: registry-image
  source:
    repository: hashicorp/terraform
    tag: 0.13.7

jobs:
- name: terraform-deplyoment
  plan:
  - get: terraform-0-13-7
  - get: terraform-repo
    trigger: true

  - task: terraform-init
    image: terraform-0-13-7
    config:
      inputs:
      - name: terraform-repo
      outputs:
      - name: terraform-repo
      platform: linux
      run:
        path: terraform
        dir: terraform-repo
        args:
        - init

  - task: terraform-plan
    image: terraform-0-13-7
    config:
      inputs:
      - name: terraform-repo
      outputs:
      - name: terraform-repo
      platform: linux
      run:
        path: terraform
        dir: terraform-repo
        args:
        - plan
        params:
          variable1: "test"
          variable2: "test2"

This is erroring out on the concourse GUI when triggering the pipeline mentioning that the vars are not available. Am I doing something wrong with the syntax?

danilopopeye
  • 9,610
  • 1
  • 23
  • 31
Lime
  • 11
  • 2
  • I could get it to work by editing the args to contain a long string with my vars. – Lime Oct 28 '21 at 07:38
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 28 '21 at 20:43

1 Answers1

1

The params are exposed to the task as environment variables so you should use them as input variables

  - task: terraform-plan
    image: terraform-0-13-7
    config:
      inputs:
      - name: terraform-repo
      outputs:
      - name: terraform-repo
      platform: linux
      run:
        path: terraform
        dir: terraform-repo
        args:
        - plan
        params:
          TF_VAR_variable1: "test"
          TF_VAR_variable2: "test2"

danilopopeye
  • 9,610
  • 1
  • 23
  • 31